Exemple #1
0
        public bool ModifyOrderMsaterForDeliver(OrderModifyModel order)
        {
            try
            {
                OrderMaster omModel = _orderMasterDao.GetOrderMasterByOrderId4Change(order.order_id);
                StringBuilder sbSql = new StringBuilder();
                sbSql.Append(@" om.order_status = 2,
os.slave_status=2,
od.detail_status=2,
om.order_date_cancel=0,
om.money_cancel=0,
om.export_flag=1,");

                sbSql.AppendFormat("om.order_date_pay ={0}", Common.CommonFunction.GetPHPTime());

                if (!isCanModifyForDeliver(order.order_id))
                {
                    return false;
                }
                //1、是否寫入對帳
                if (order.isBilling_checked)
                {
                    sbSql.Append(",om.billing_checked=1,");
                    sbSql.AppendFormat("om.money_collect_date={0}", Common.CommonFunction.GetPHPTime());
                }
                //2、紅利折抵
                if (order.deduct_card_bonus != 0)
                {
                    if (omModel.Order_Amount < order.deduct_card_bonus)
                    {
                        return false;
                    }
                    sbSql.AppendFormat(",om.deduct_card_bonus={0},", order.deduct_card_bonus);
                    sbSql.AppendFormat("om.order_amount={0}", omModel.Order_Amount - order.deduct_card_bonus);
                }
                //3、要不要扣除消費者抵用購物金
                if (order.isCash_record_bonus)
                {
                    order.user_id = Convert.ToInt32(omModel.user_id);
                    //order.bonus_num = 
                    order.bonus_num = Convert.ToInt32(omModel.Deduct_Bonus);

                    order.record_note = "強制轉單扣點";
                    order.record_writer = "server";
                    AddBonusRecord(order);//扣除

                }

                #region //4、要不要給hg點或購物金
                if (order.isHGBonus)
                {
                    #region 購物金
                    if (omModel.Accumulated_Bonus > 0)
                    {
                        //訂單取消後,回撥購物金的使用日期限制
                        int nExpire_Day = 90;
                        DateTime nMaster_Start = DateTime.Now.Date;
                        DateTime nMaster_End = DateTime.Now.AddDays(omModel.BonusExpireDay).Date.AddSeconds(-1);
                        // DateTime nMaster_End = DateTime.Now.AddDays(1).Date.AddSeconds(-1);

                        //OrderModifyModel orderModifyModel = new OrderModifyModel();
                        ////$amego_bonus->bonus_master_add($aOrder['user_id'], 30, $aOrder['accumulated_bonus'], $nMaster_Start, $nMaster_End, $aOrder['order_id'], '商品回饋購物金' , 1);
                        //orderModifyModel.user_id =Convert.ToInt32( omModel.User_Id);
                        //orderModifyModel.order_id = Convert.ToInt32(omModel.Order_Id);
                        //orderModifyModel.bonus_num = Convert.ToInt32(omModel.Deduct_Bonus);
                        //orderModifyModel.use_note ="強制轉單扣點";
                        //orderModifyModel.use_writer = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                        // 會員目前可用購物金
                        BonusMasterQuery query = new BonusMasterQuery();
                        query.user_id = omModel.User_Id;
                        query.type_id = 30;
                        query.master_total = Convert.ToUInt32(omModel.Accumulated_Bonus);
                        query.master_balance = omModel.Accumulated_Bonus;
                        query.smaster_start = nMaster_Start;
                        query.smaster_end = nMaster_End;
                        query.smaster_createtime = DateTime.Now;
                        query.smaster_updatedate = DateTime.Now;
                        query.master_writer = string.Format("Writer:{0}", (System.Web.HttpContext.Current.Session["caller"] as Caller).user_username);

                        query.bonus_type = 1;
                        query.master_note = "商品回饋購物金";
                        //Serial ser = _serialDao.GetSerialById(27);
                        //ser.Serial_Value = ser.Serial_Value+1;
                        //_serialDao.Update(ser);
                        //query.master_id = Convert.ToUInt32(ser.Serial_Value);
                        query.master_ipfrom = order.ip_from;
                        List<BonusMasterQuery> queryList = new List<BonusMasterQuery>();
                        queryList.Add(query);
                        _bonusMasterMgr.BonusMasterAdd(queryList);
                        //bonusMasterDao.InsertBonusMaster(query); 
                    }
                    #endregion
                    #region hg點
                    if (omModel.Accumulated_Happygo > 0)
                    {
                        if (_happyGoMgr.GetHGDeductList(omModel.Order_Id).Count > 0)
                        {
                            //有則進行點數累積,無則發信通知
                        }
                        else
                        {
                            MailHelper mailHelper = new MailHelper();
                            string MailTitle = "HG累點失敗";
                            string MailBody = string.Format("{0}無HG資料,無法累點。", omModel.Order_Id);
                            mailHelper.SendToGroup("BonusFailure", MailTitle, MailBody);
                        }

                    }
                    #endregion
                }
                #endregion
                //更新條件
                StringBuilder sql = new StringBuilder();
                sql.Append(@"update order_master om,order_slave os,order_detail od
set ");
                sql.Append(sbSql);
                sql.AppendFormat(@" where om.order_id={0}  AND om.order_id = os.order_id
 AND os.slave_id = od.slave_id ", order.order_id);
                try
                {
                    _orderMasterDao.UpdateOrderMaster(sql.ToString());
                    return true;
                }
                catch (Exception ex)
                {
                    throw new Exception("OrderMasterMgr-->ModifyOrderMsaterForDeliver-->" + ex.Message, ex);

                }
            }
            catch (Exception ex)
            {

                throw new Exception("OrderMasterMgr-->ModifyOrderMsaterForDeliver-->" + ex.Message, ex);
            }

        }
Exemple #2
0
 public void AddBonusRecord(OrderModifyModel model)
 {
     // 會員目前可用購物金
     int userBonus = bonusMasterDao.GetUserBonus(model.user_id);
     if (model.bonus_num < 0)
     {
         model.bonus_num = model.bonus_num * -1;
     }
     if (model.bonus_num > userBonus)
     {
         return;
     }
     List<BonusMasterQuery> bonusQuery = bonusMasterDao.GetBonusMasterListByUser(model.user_id);
     foreach (BonusMasterQuery bonus in bonusQuery)
     {
         if (model.bonus_num > 0)
         {
             BonusRecord bonusRecord = new BonusRecord();
             int decuteBonusNum = bonus.master_balance > model.bonus_num ? model.bonus_num : bonus.master_balance;
             Serial ser = _serialDao.GetSerialById(28);
             ser.Serial_Value = ser.Serial_Value + 1;
             _serialDao.Update(ser);
             bonusRecord.record_id = Convert.ToUInt32(ser.Serial_Value);
             bonusRecord.master_id = bonus.master_id;
             bonusRecord.type_id = bonus.type_id;
             bonusRecord.order_id = Convert.ToUInt32(model.order_id);
             bonusRecord.record_use = Convert.ToUInt32(decuteBonusNum);
             bonusRecord.record_note = model.record_note;
             bonusRecord.record_writer = model.record_writer;
             bonusRecord.record_ipfrom = model.ip_from;
             bonusMasterDao.InsertIntoBonusRecord(bonusRecord);
             bonus.master_balance = bonus.master_balance - decuteBonusNum;//減去扣除的購物金
             bonusMasterDao.UpdateBonusMasterMasterBalance(bonus);
             model.bonus_num -= decuteBonusNum;//更新
         }
         else
         {
             return;
         }
     }
 }
        public HttpResponseBase OrderMasterChangeStatusFromPayToDel()
        {
            string json = json = "{success:true,data:''}"; ;
            OrderModifyModel orderModifyModel = new OrderModifyModel();


            try
            {
                if (!string.IsNullOrEmpty(Request.Params["order_id"]))
                {
                    orderModifyModel.order_id = Convert.ToInt32(Request.Params["order_id"]);

                }
                if (!string.IsNullOrEmpty(Request.Params["deduct_card_bonus"]))
                {
                    orderModifyModel.deduct_card_bonus = Convert.ToInt32(Request.Params["deduct_card_bonus"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["isBilling_checked"]))
                {
                    orderModifyModel.isBilling_checked = Convert.ToBoolean(Request.Params["isBilling_checked"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["isHGBonus"]))
                {
                    orderModifyModel.isHGBonus = Convert.ToBoolean(Request.Params["isHGBonus"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["isCash_record_bonus"]))
                {
                    orderModifyModel.isCash_record_bonus = Convert.ToBoolean(Request.Params["isCash_record_bonus"]);
                }
                OrderMasterMgr orderMasterMgr = new OrderMasterMgr(connectionString);
                orderModifyModel.ip_from = CommonFunction.GetIP4Address(Request.UserHostAddress);
                //如果不可以轉單,則返回不可以
                if (!orderMasterMgr.ModifyOrderMsaterForDeliver(orderModifyModel))
                {
                    json = "{success:false,data:'此訂單不可轉出貨單'}";
                }
                else
                {
                    try
                    {
                        orderMasterMgr.ModifyOrderMsaterForDeliver(orderModifyModel);
                        json = "{success:true,data:'恭喜!轉單成功'}";
                    }
                    catch (Exception ex)
                    {

                        Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                        logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                        logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                        log.Error(logMessage);
                        json = "{success:false,data:'轉單失敗!'}";
                    }

                }
            }
            catch (Exception ex)
            {

                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,data:'系統故障!'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }