Service/CommonTrigger/CommonService.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Common;
using Domain;
using Domain.TriggerMdl;
using IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;

namespace Service.CommonTrigger
{
    public class CommonService : ICommonService
    {
        private IPointTriggerService _IPoint { get; set; }

        private IVoucherTriggerService _IVoucher { get; set; }

        private ICashAccountLogService _ICash { get; set; }

        public CommonService(IPointTriggerService IPoint, IVoucherTriggerService IVoucher, ICashAccountLogService ICash)
        {
            this._IPoint = IPoint;
            this._IVoucher = IVoucher;
            this._ICash = ICash;
        }
        /// <summary>
        /// 积分  优惠券  现金账户  三者调用唯一入口点
        /// </summary>
        /// <param name="pc">积分参数 具体参考PointRuleService  add为添加积分  del为扣除积分</param>
        /// <param name="cal">现金账户参数 具体参考CashAccountLogService</param>
        /// <param name="vop">优惠券参数 具体参考VoucherOptionService  add为派发代金券  del为扣除代金券</param>
        /// <returns></returns>
        public bool CVPCommonAPI(PointCondition pcadd, PointCondition pcdel, CashAccountLogMdl cal, VoucherOption vopadd, VoucherOption vopdel)
        {
            //本地事物实现
            Transaction originalTransaction = Transaction.Current;
            CommittableTransaction transaction = new CommittableTransaction();
            string Message="";
            bool flag = true;
            try
            {
                Transaction.Current = transaction;
                //-----------------------------------------
                //首先  扣除积分数  抵扣积分必须大于0 才需要执行
                if(pcdel.PointLimit>0)
                    _IPoint.APIPointToMoney(pcdel);

                //积分扣除后  如果满足积分累计规则  进行积分累计
                _IPoint.APICustomerPoint(pcadd);

                //进行现金账户金额消费  只有当支付方式为账户余额时  才需要执行该方法
                if (cal.PayMethod == (int)EnumCE.PayMethodEM.Balance)
                    _ICash.insertApiCashAccountLog((decimal)cal.AmountValue,out Message,cal);

                //进行代金券抵扣  如果选择了代金券抵扣 才需要执行
                if (!string.IsNullOrEmpty(vopdel.LssueVoucher_ID))
                    _IVoucher.saveVoucherTouch(vopdel,out Message);

后面还有 22 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。