Beispiel #1
0
        /// <summary>
        /// 销售还款
        /// </summary>
        /// <param name="userContext"></param>
        /// <param name="salesId"></param>
        /// <param name="money"></param>
        /// <param name="remark"></param>
        /// <param name="sendsms"></param>
        /// <returns></returns>
        public int SalesRepayment(UserContext userContext, int salesId, decimal money, string remark, int sendsms,
                                  int operatorID)
        {
            var salesInfo = _salesDapperRepository.Find(x => x.saleID == salesId && x.accID == userContext.AccId);

            if (salesInfo == null)
            {
                return(-1);
            }
            else if (salesInfo.UnpaidMoney <= 0)
            {
                return(-2);
            }
            else
            {
                var updateSalesInfo = new SalesInfo();
                updateSalesInfo.accID       = userContext.AccId;
                updateSalesInfo.saleID      = salesId;
                updateSalesInfo.UnpaidMoney = salesInfo.UnpaidMoney - money;
                updateSalesInfo.CashMoney   = salesInfo.CashMoney + money;

                bool result = _salesDapperRepository.Update <SalesInfo>(updateSalesInfo,
                                                                        item => new { item.UnpaidMoney, item.CashMoney });

                if (result)
                {
                    var logModel = new SaleLogInfo
                    {
                        accID       = userContext.AccId,
                        saleID      = salesId,
                        saleListID  = 0,
                        logType     = 3,
                        itemType    = 0,
                        OriginalVal = salesInfo.UnpaidMoney,
                        EditVal     = money
                    };
                    logModel.FinalVal      = logModel.OriginalVal - logModel.EditVal;
                    logModel.LogTime       = DateTime.Now;
                    logModel.operatorTime  = DateTime.Now;
                    logModel.operatorID    = userContext.Operater;
                    logModel.operatorIP    = userContext.IpAddress;
                    logModel.addedLgUserId = operatorID == 0 ? userContext.Operater : operatorID;
                    logModel.Remark        = remark;
                    logModel.Flag          = "";

                    _salesLogDapperRepository.Insert(logModel);

                    if (sendsms == 1)
                    {
                        //TODO 接统一短信接口
                    }
                }

                return(result ? 1 : 0);
            }
        }
Beispiel #2
0
 public NewSaleLogEvent(SaleLogInfo saleLogInfo)
 {
     SaleLogInfo = saleLogInfo;
 }