Esempio n. 1
0
        public JsResultObject submitComment(MemberCommentModel comment)
        {
            JsResultObject        re    = new JsResultObject();
            OrderModel            order = BaseZdBiz.Load <OrderModel>(comment.orderFk);
            MemberRewardRuleModel rule  = GetCurRewardRule();

            if (order.checkOutDate.AddDays(rule.comValidityDays).CompareTo(DateTime.Now) < 0)
            {
                re.code = JsResultObject.CODE_ERROR;
                re.msg  = string.Format("离店日期超出{0}日", rule.comValidityDays);
                return(re);
            }

            comment.createDate = DateTime.Now;
            comment.setPk(comment.createPk());
            re = BaseZdBiz.Save(comment);
            order.orderStatus = OrderModel.ORDER_STATUS_COMMENTED;
            re = BaseZdBiz.Update(order, "");
            MemberModel        member     = BaseZdBiz.Load <MemberModel>(comment.memberFk);
            MemberAccountModel oldAccount = getCurrMemberAccount(member);
            MemberAccountModel newAccount = new MemberAccountModel(comment.memberFk);

            newAccount.method       = MemberAccountModel.METHOD_COMMENT_REWARD;
            newAccount.createDate   = DateTime.Now;
            newAccount.method       = MemberAccountModel.METHOD_COMMENT_REWARD;
            newAccount.oldAmount    = oldAccount.newAmount;
            newAccount.changeAmount = Convert.ToInt32(GetReward(order).amount);
            newAccount.newAmount    = newAccount.oldAmount + newAccount.changeAmount;
            newAccount.setPk(newAccount.createPk());
            re = BaseZdBiz.Save(newAccount);

            return(re);
        }
Esempio n. 2
0
        public MemberRewardRuleModel GetCurRewardRule()
        {
            MemberRewardRuleModel rule = BaseZdBiz.Load <MemberRewardRuleModel>("default");

            if (rule == null)
            {
                ICriteria icr = BaseZdBiz.CreateCriteria <MemberRewardRuleModel>();
                rule = icr.List <MemberRewardRuleModel>()[0];
            }
            return(rule);
        }
Esempio n. 3
0
        public ActionResult SaveMemberCommentRewardRule()
        {
            MemberRewardRuleModel e = new MemberRewardRuleModel();

            e = ObjectUtil.Eval(e, Request.Params, "", "");
            if (string.IsNullOrEmpty(e.id))
            {
                e.id = e.createPk().ToString();
            }
            JsResultObject result = BaseZdBiz.SaveOrUpdate(e, "会员点评规则");

            return(JsonText(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        private MemberRewardModel GetReward(OrderModel order)
        {
            MemberRewardRuleModel rule   = GetCurRewardRule();
            MemberRewardModel     reward = new MemberRewardModel();

            reward.setPk(reward.createPk());
            reward.createDate = DateTime.Now;
            if (order.totalPrice < rule.rebateScaleAmount)
            {
                reward.amount = rule.rebateAmount;
            }
            else
            {
                reward.amount = (float)(order.totalPrice * rule.rebateScale);
            }
            reward.memberFk = order.memberFk;
            return(reward);
        }
Esempio n. 5
0
        public JsResultObject submitMemberRegInfo(MemberModel member)
        {
            JsResultObject re = BaseZdBiz.Save(member);

            if (re.code == JsResultObject.CODE_SUCCESS)
            {
                MemberRewardRuleModel rule    = GetCurRewardRule();
                MemberAccountModel    account = new MemberAccountModel(member.id);
                account.oldAmount    = 0;
                account.newAmount    = 10;
                account.changeAmount = 10;
                account.createDate   = DateTime.Now;
                account.method       = MemberAccountModel.METHOD_ACCOUNT_CREATE;
                account.remark       = string.Format("帐号创建成功,获得奖励{0}元", 10);
                account.setPk(account.createPk());
                re = BaseZdBiz.Save(account);
            }
            return(re);
        }
Esempio n. 6
0
 public ActionResult SaveMemberCommentRewardRule()
 {
     MemberRewardRuleModel e = new MemberRewardRuleModel();
     e = ObjectUtil.Eval(e, Request.Params, "", "");
     if (string.IsNullOrEmpty(e.id))
     {
         e.id = e.createPk().ToString();
     }
     JsResultObject result = BaseZdBiz.SaveOrUpdate(e, "会员点评规则");
     return JsonText(result, JsonRequestBehavior.AllowGet);
 }