public async Task SetPayStatus(Enroll enroll, Member member, EnrollStatus enrollStatus, string strPayType)
        {
            if (enroll.Status == enrollStatus)
            {
                return;
            }

            enroll.Status   = enrollStatus;
            enroll.PaidTime = DateTime.Now;

            bool bIsPaid = enrollStatus == EnrollStatus.PaySuccess;

            if (bIsPaid)//支付成功
            {
                enroll.PayType = strPayType;
                enroll.Note    = "已完成支付";
            }
            else
            {
                enroll.PayType = "";
                enroll.Note    = "已完成撤销支付";
            }

            PayRecordHelper helper = new PayRecordHelper();
            await helper.SaveAsycn(enroll, bIsPaid);

            await ScoreRule(enroll, member, bIsPaid, true);

            await SaveChangesAsync();
        }
Example #2
0
        public async Task <bool> Approve(int id)
        {
            Withdraw withdraw = await GetByIdAsync <Withdraw>(id);

            if (withdraw.Status == WithdrawStatus.APPROVED)
            {
                return(true);
            }

            Member member = await GetByIdAsync <Member>(withdraw.MemberId);

            if (member.Score < withdraw.Score)
            {
                return(false);
            }

            withdraw.Status      = WithdrawStatus.APPROVED;
            withdraw.OperateTime = DateTime.Now;

            WithdrawType withdrawType = await GetDbSet <WithdrawType>().Where(o => o.Id == withdraw.WithdrawTypeId).FirstOrDefaultAsync();

            PayRecordHelper payRecordHelper = new PayRecordHelper();
            await payRecordHelper.SaveAsycn(withdraw, withdrawType, member);

            string strMsg = string.Empty;

            SMSHelper.SendPay(member.Phone, withdraw.Score - withdraw.Score * withdraw.TaxPercentage, withdrawType.Name, out strMsg);

            MemberHelper memberHelper = new MemberHelper();
            await memberHelper.AddScore(member, -withdraw.Score, withdrawType.Name + "提现", true);

            return(await SaveChangesAsync());
        }