Exemplo n.º 1
0
 function ordercontrol()
 {
     $id = intval(IReq::get('id'));
     $type = IReq::get('type');
     if (empty($id)) {
         $this->message('订单ID错误');
     }
     $orderinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "order where id='" . $id . "'  ");
     if (empty($orderinfo)) {
         $this->message('订单获取失败');
     }
     switch ($type) {
         case 'un':
             //关闭订单
             $reasons = IReq::get('reasons');
             $suresend = IReq::get('suresend');
             if (empty($reasons)) {
                 $this->message('关闭理由不能为空');
             }
             if ($orderinfo['status'] > 2) {
                 $this->message('订单状态不可关闭');
             }
             //更新订单
             //写消息给买家
             if (!empty($orderinfo['buyeruid'])) {
                 $detail = '';
                 $memberinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $orderinfo['buyeruid'] . "'   ");
                 if ($orderinfo['paystatus'] == 1 && $orderinfo['paytype'] != 'outpay') {
                     //将订单还给买家账号
                     /*
                     if(!empty($memberinfo)){
                      $this->mysql->update(Mysite::$app->config['tablepre'].'member','`cost`=`cost`+'.$orderinfo['allcost'].',`score`=`score`+'.$orderinfo['scoredown'],"uid ='".$orderinfo['buyeruid']."' ");
                       $detail = ',账号余额增加'.$orderinfo['allcost'].'元';
                     }
                     $membersc = $memberinfo['score']+$orderinfo['allcost'];
                     $this->memberCls->addlog($orderinfo['buyeruid'],2,1,$orderinfo['allcost'],'取消订单','管理员关闭订单'.$orderinfo['dno'].'已支付金额'.$orderinfo['allcost'].'返回帐号',$membersc);
                     */
                     $this->message('订单已支付,请在退款处理中关闭该订单');
                     if ($orderinfo['scoredown'] > 0) {
                         $memberscs = $memberinfo['score'] + $orderinfo['scoredown'];
                         $this->memberCls->addlog($orderinfo['buyeruid'], 1, 1, $orderinfo['scoredown'], '取消订单', '管理员关闭订单' . $orderinfo['dno'] . '抵扣积分' . $orderinfo['scoredown'] . '返回帐号', $memberscs);
                     }
                 } elseif ($orderinfo['scoredown'] > 0) {
                     $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`score`=`score`+' . $orderinfo['scoredown'], "uid ='" . $orderinfo['buyeruid'] . "' ");
                     $memberscs = $memberinfo['score'] + $orderinfo['scoredown'];
                     $this->memberCls->addlog($orderinfo['buyeruid'], 1, 1, $orderinfo['scoredown'], '取消订单', '管理员关闭订单' . $orderinfo['dno'] . '抵扣积分' . $orderinfo['scoredown'] . '返回帐号', $memberscs);
                 }
             }
             $orderdata['status'] = 5;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $orderdata, "id='" . $id . "'");
             //还库存
             $ordetinfo = $this->mysql->getarr("select ort.goodscount,go.id,go.sellcount,go.count as stroe from " . Mysite::$app->config['tablepre'] . "orderdet as ort left join  " . Mysite::$app->config['tablepre'] . "goods as go on go.id = ort.goodsid   where ort.order_id='" . $id . "' and  go.id > 0 ");
             $day = strtotime(date('Y-m-d', $orderinfo['posttime']));
             foreach ($ordetinfo as $key => $value) {
                 //$newdata['count'] = $value['stroe']+	$value['goodscount'];
                 $newdata['sellcount'] = $value['sellcount'] - $value['goodscount'];
                 //$this->mysql->update(Mysite::$app->config['tablepre']."goods",$newdata,"id='".$value['id']."'");
                 //modified by pinkky
                 $this->mysql->update(Mysite::$app->config['tablepre'] . "goods", $newdata, "id='" . $value['id'] . "'");
                 $this->mysql->update(Mysite::$app->config['tablepre'] . "daystock", '`stock`=`stock`-' . $value['goodscount'], "goods_id=" . $value['id'] . " and day=" . $day);
             }
             if ($suresend == 1) {
                 //短信发送
                 $ordCls = new orderclass($this->mysql);
                 $ordCls->noticeclose($id, $reasons);
             }
             break;
         case 'pass':
             if ($orderinfo['status'] != 0) {
                 $this->message('订单状态不可通过审核');
             }
             if ($orderinfo['is_reback'] > 0 && $orderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             $checkstr = Mysite::$app->config['auto_send'];
             if ($checkstr == 1) {
                 $orderdata['status'] = 2;
             } else {
                 $orderdata['status'] = 1;
             }
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $orderdata, "id='" . $id . "'");
             if (Mysite::$app->config['man_ispass'] == 1) {
                 $ordCls = new orderclass($this->mysql);
                 $ordCls->sendmess($id);
             }
             break;
         case 'send':
             if ($orderinfo['is_reback'] > 0 && $orderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             if ($orderinfo['status'] != 1) {
                 $this->message('订单状态不可发货');
             }
             $orderdata['status'] = 2;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $orderdata, "id='" . $id . "'");
             $ordCls = new orderclass($this->mysql);
             $ordCls->noticesend($id);
             break;
         case 'over':
             if ($orderinfo['is_reback'] > 0 && $orderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             if ($orderinfo['status'] != 2) {
                 $this->message('订单状态不可完成');
             }
             $orderdata['status'] = 3;
             //写用户数据
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $orderdata, "id='" . $id . "'");
             //更新用户成长值
             if (!empty($orderinfo['buyeruid'])) {
                 $memberinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $orderinfo['buyeruid'] . "'   ");
                 if (!empty($memberinfo)) {
                     $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`total`=`total`+' . $orderinfo['allcost'], "uid ='" . $orderinfo['buyeruid'] . "' ");
                 }
                 /*
                  // 写优惠券
                 */
                 if ($memberinfo['parent_id'] > 0) {
                     $upuser = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $memberinfo['parent_id'] . "'   ");
                     if (!empty($upuser)) {
                         if (Mysite::$app->config['tui_juan'] == 1) {
                             $nowtime = time();
                             $endtime = $nowtime + Mysite::$app->config['tui_juanday'] * 24 * 60 * 60;
                             $juandata['card'] = $nowtime . rand(100, 999);
                             $juandata['card_password'] = substr(md5($juandata['card']), 0, 5);
                             $juandata['status'] = 1;
                             // 状态,0未使用,1已绑定,2已使用,3无效
                             $juandata['creattime'] = $nowtime;
                             // 制造时间
                             $juandata['cost'] = Mysite::$app->config['tui_juancost'];
                             // 优惠金额
                             $juandata['limitcost'] = Mysite::$app->config['tui_juanlimit'];
                             // 购物车限制金额下限
                             $juandata['endtime'] = $endtime;
                             // 失效时间
                             $juandata['uid'] = $upuser['uid'];
                             // 用户ID
                             $juandata['username'] = $upuser['username'];
                             // 用户名
                             $juandata['name'] = '推荐送优惠券';
                             //  优惠券名称
                             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata);
                             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`parent_id`=0', "uid ='" . $orderinfo['buyeruid'] . "' ");
                             $logdata['uid'] = $upuser['uid'];
                             $logdata['childusername'] = $memberinfo['username'];
                             $logdata['titile'] = '推荐送优惠券';
                             $logdata['addtime'] = time();
                             $logdata['content'] = '被推荐下单完成';
                             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'sharealog', $logdata);
                         }
                     }
                 }
             }
             break;
         case 'del':
             if ($orderinfo['status'] < 4) {
                 $this->message('订单状态不可删除');
             }
             $this->mysql->delete(Mysite::$app->config['tablepre'] . 'order', "id = '{$id}'");
             break;
         case 'drawback':
             //退款成功
             //获取退款记录
             $drawbacklog = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "drawbacklog where orderid=" . $id . " order by  id desc  limit 0,2");
             if (empty($drawbacklog)) {
                 $this->message('退款记录为空');
             }
             if ($drawbacklog['status'] != 0) {
                 $this->message('退款记录状态不可操作');
             }
             if ($orderinfo['status'] > 2) {
                 $this->message('订单状态' . $orderinfo['status'] . '不可操作退款');
             }
             $arr['is_reback'] = 2;
             //订单状态
             $arr['status'] = 4;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $arr, "id='" . $id . "'");
             $data['bkcontent'] = IReq::get('reasons');
             $data['status'] = 1;
             //
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'drawbacklog', $data, "id='" . $drawbacklog['id'] . "'");
             $ordCls = new orderclass($this->mysql);
             $ordCls->noticeback($id);
             break;
         case 'undrawback':
             //退款不成功
             $drawbacklog = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "drawbacklog where orderid=" . $id . " order by  id desc  limit 0,2");
             if (empty($drawbacklog)) {
                 $this->message('退款记录为空');
             }
             if ($drawbacklog['status'] != 0) {
                 $this->message('退款记录状态不可操作');
             }
             if ($orderinfo['status'] > 2) {
                 $this->message('订单状态不可操作退款');
             }
             $arr['is_reback'] = 3;
             //订单状态
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $arr, "id='" . $id . "'");
             $data['bkcontent'] = IReq::get('reasons');
             $data['status'] = 2;
             //
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'drawbacklog', $data, "id='" . $drawbacklog['id'] . "'");
             $ordCls = new orderclass($this->mysql);
             $ordCls->noticeunback($id);
             break;
         default:
             $this->message('未定义的操作');
             break;
     }
     $this->success('操作成功');
     //返回json_code;
 }
Exemplo n.º 2
0
 function shopcontrol()
 {
     $this->checkshoplogin();
     $controlname = trim(IFilter::act(IReq::get('controlname')));
     $orderid = intval(IReq::get('orderid'));
     $shopid = ICookie::get('adminshopid');
     if (empty($shopid)) {
         $this->message('COOK失效,请重新登陆');
     }
     $shopinfo = $this->mysql->select_one("select uid from " . Mysite::$app->config['tablepre'] . "shop where id = " . $shopid . "");
     switch ($controlname) {
         case 'unorder':
             if ($orderinfo['is_reback'] > 0 && $orderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             $reason = trim(IFilter::act(IReq::get('reason')));
             if (empty($reason)) {
                 $this->message('关闭理由不能为空');
             }
             $ordercontrol = new ordercontrol($orderid);
             if ($ordercontrol->sellerunorder($shopinfo['uid'], $reason)) {
                 $ordCls = new orderclass($this->mysql);
                 $ordCls->noticeclose($orderid, $reason);
                 $this->success('操作成功');
             } else {
                 $this->message($ordercontrol->Error());
             }
             break;
         case 'makeorder':
             //制作该订单
             $checkorderinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "order where id = " . $orderid . " and shopid=" . $shopid . " ");
             if (empty($checkorderinfo)) {
                 $this->message('订单不存在');
             }
             if ($checkorderinfo['status'] != 1) {
                 $this->message('不可操作');
             }
             if (!empty($checkorderinfo['is_make'])) {
                 $this->message('不可操作');
             }
             if ($checkorderinfo['is_reback'] > 0 && $checkorderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             $udata['is_make'] = 1;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $udata, "id='" . $orderid . "'");
             $ordCls = new orderclass($this->mysql);
             $ordCls->noticemake($orderid);
             $this->success('操作成功');
             break;
         case 'unmakeorder':
             //不制作该订单
             $checkorderinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "order where id = " . $orderid . " and shopid=" . $shopid . " ");
             if (empty($checkorderinfo)) {
                 $this->message('订单不存在');
             }
             if ($checkorderinfo['is_reback'] > 0 && $checkorderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             if ($checkorderinfo['status'] != 1) {
                 $this->message('不可操作');
             }
             if (!empty($checkorderinfo['is_make'])) {
                 $this->message('不可操作');
             }
             $udata['is_make'] = 2;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $udata, "id='" . $orderid . "'");
             $ordCls = new orderclass($this->mysql);
             $ordCls->noticeunmake($orderid);
             $this->success('操作成功');
             break;
         case 'sendorder':
             $ordercontrol = new ordercontrol($orderid);
             if ($ordercontrol->sendorder($shopinfo['uid'])) {
                 $ordCls = new orderclass($this->mysql);
                 $ordCls->noticesend($orderid);
                 $this->success('操作成功');
             } else {
                 $this->message($ordercontrol->Error());
             }
             break;
         case 'shenhe':
             $ordercontrol = new ordercontrol($orderid);
             if ($ordercontrol->shenhe($shopinfo['uid'])) {
                 $this->success('操作成功');
             } else {
                 $this->message($ordercontrol->Error());
             }
             break;
         case 'delorder':
             $ordercontrol = new ordercontrol($orderid);
             if ($ordercontrol->sellerdelorder($shopinfo['uid'])) {
                 $this->success('操作成功');
             } else {
                 $this->message($ordercontrol->Error());
             }
             break;
         case 'wancheng':
             $checkorderinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "order where id = " . $orderid . " and shopid=" . $shopid . " ");
             if ($checkorderinfo['is_reback'] > 0 && $checkorderinfo['is_reback'] < 3) {
                 $this->message('订单退款中不可操作');
             }
             if ($checkorderinfo['status'] != 2) {
                 $this->message('订单状态不可完成');
             }
             $orderdata['status'] = 3;
             //写用户数据
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'order', $orderdata, "id='" . $orderid . "'");
             //更新用户成长值
             if (!empty($orderinfo['buyeruid'])) {
                 $memberinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $checkorderinfo['buyeruid'] . "'   ");
                 if (!empty($memberinfo)) {
                     $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`total`=`total`+' . $checkorderinfo['allcost'], "uid ='" . $checkorderinfo['buyeruid'] . "' ");
                 }
                 /*
                  // 写优惠券
                 */
                 if ($memberinfo['parent_id'] > 0) {
                     $upuser = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $memberinfo['parent_id'] . "'   ");
                     if (!empty($upuser)) {
                         if (Mysite::$app->config['tui_juan'] == 1) {
                             $nowtime = time();
                             $endtime = $nowtime + Mysite::$app->config['tui_juanday'] * 24 * 60 * 60;
                             $juandata['card'] = $nowtime . rand(100, 999);
                             $juandata['card_password'] = substr(md5($juandata['card']), 0, 5);
                             $juandata['status'] = 1;
                             // 状态,0未使用,1已绑定,2已使用,3无效
                             $juandata['creattime'] = $nowtime;
                             // 制造时间
                             $juandata['cost'] = Mysite::$app->config['tui_juancost'];
                             // 优惠金额
                             $juandata['limitcost'] = Mysite::$app->config['tui_juanlimit'];
                             // 购物车限制金额下限
                             $juandata['endtime'] = $endtime;
                             // 失效时间
                             $juandata['uid'] = $upuser['uid'];
                             // 用户ID
                             $juandata['username'] = $upuser['username'];
                             // 用户名
                             $juandata['name'] = '推荐送优惠券';
                             //  优惠券名称
                             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata);
                             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`parent_id`=0', "uid ='" . $checkorderinfo['buyeruid'] . "' ");
                             $logdata['uid'] = $upuser['uid'];
                             $logdata['childusername'] = $memberinfo['username'];
                             $logdata['titile'] = '推荐送优惠券';
                             $logdata['addtime'] = time();
                             $logdata['content'] = '被推荐下单完成';
                             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'sharealog', $logdata);
                         }
                     }
                 }
             }
             $this->success('操作成功');
             break;
         default:
             $this->message('未定义的操作');
             break;
     }
 }