Esempio n. 1
0
 /**
  * 创建文件夹
  * @param $ordername 品牌id
  * @param $ordername 订单号名字
  * @param $brandnumberarray	款号数组
  */
 public static function create_order($brandid, $ordername, $brandnumberarray = array())
 {
     $arr = array();
     $output = '';
     $memcache = md5('getbrandsku' . $brandid);
     $boo = Yii::app()->cache->get($memcache);
     //缓存 不存在时候调用
     if (empty($boo)) {
         $arr = Yii::app()->db->createCommand()->select('code_start,code_end')->from('beu_brand')->where("id={$brandid}")->queryRow();
         if (!empty($arr)) {
             $output = json_encode($arry);
             Yii::app()->cache->set($output, $memcache, 18000);
             //添加缓存
         }
     } else {
         $arr = json_decode($boo, true);
     }
     if (count($brandnumberarray) > 0) {
         if (!empty($arr)) {
             $start = $arr['code_start'];
             //开始
             $end = $arr['code_end'];
             //结束
             foreach ($brandnumberarray as $value) {
                 $brand_sku = substr($value, $start, $end - $start);
                 if (!empty($value)) {
                     $url = $_SERVER['DOCUMENT_ROOT'] . '/orderlist/' . $ordername . '/' . $brand_sku . '/' . $value . '/product/';
                     orderclass::createFolder($url);
                     $url = $_SERVER['DOCUMENT_ROOT'] . '/orderlist/' . $ordername . '/' . $brand_sku . '/' . $value . '/model/';
                     orderclass::createFolder($url);
                     $url = $_SERVER['DOCUMENT_ROOT'] . '/orderlist/' . $ordername . '/' . $brand_sku . '/' . $value . '/details/';
                     orderclass::createFolder($url);
                 }
             }
         }
     }
     return true;
     //创建成功返回
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 function makeorder()
 {
     $info['shopid'] = intval(IReq::get('shopid'));
     //店铺ID
     $info['remark'] = IFilter::act(IReq::get('remark'));
     //备注
     $info['paytype'] = IFilter::act(IReq::get('paytype'));
     //支付方式
     $info['dikou'] = intval(IReq::get('dikou'));
     //抵扣金额
     $info['username'] = IFilter::act(IReq::get('username'));
     $info['mobile'] = IFilter::act(IReq::get('mobile'));
     $info['addressdet'] = IFilter::act(IReq::get('addressdet'));
     $info['senddate'] = IFilter::act(IReq::get('senddate'));
     $info['minit'] = IFilter::act(IReq::get('minit'));
     $info['juanid'] = intval(IReq::get('juanid'));
     //优惠劵ID
     $info['ordertype'] = 1;
     //订单类型
     $peopleNum = IFilter::act(IReq::get('peopleNum'));
     $info['othercontent'] = '';
     //empty($peopleNum)?'':serialize(array('人数'=>$peopleNum));
     if (empty($info['shopid'])) {
         $this->message('店铺ID错误');
     }
     $Cart = new smCart();
     $carinfo = $Cart->getMyCart();
     //print_r($carinfo);exit;
     if (!isset($carinfo['list'][$info['shopid']]['data'])) {
         $this->message('对应店铺购物车商品为空');
     }
     if ($carinfo['list'][$info['shopid']]['shopinfo']['shoptype'] == 1) {
         $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopmarket as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     } else {
         $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     }
     if (empty($shopinfo)) {
         $this->message('店铺获取失败');
     }
     $checkps = $this->pscost($shopinfo, $carinfo['list'][$info['shopid']]['count']);
     if ($checkps['canps'] != 1) {
         $this->message('该店铺不在配送范围内');
     }
     $info['cattype'] = 0;
     //
     if (empty($info['username'])) {
         $this->message('联系人不能为空');
     }
     if (!IValidate::suremobi($info['mobile'])) {
         $this->message('请输入正确的手机号');
     }
     if (empty($info['addressdet'])) {
         $this->message('详细地址为空');
     }
     $info['userid'] = !isset($this->member['score']) ? '0' : $this->member['uid'];
     if (Mysite::$app->config['allowedguestbuy'] != 1) {
         if ($info['userid'] == 0) {
             $this->message('禁止游客下单');
         }
     }
     //判断库存
     $senddate = $info['senddate'];
     $minit = $info['minit'];
     $nowpost = strtotime($senddate . ' ' . $minit);
     $day = strtotime(date('Y-m-d', $nowpost));
     $goods_id_list = [];
     foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) {
         $goods_id_list[] = $value['id'];
     }
     $goods_ids = implode(',', $goods_id_list);
     $stock_info_list = $this->mysql->getarr("SELECT goods_id,stock FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id in ({$goods_ids}) AND day={$day}");
     $stock_list = [];
     foreach ($stock_info_list as $key => $value) {
         $stock_list[$value['goods_id']] = $value['stock'];
     }
     foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) {
         if (!array_key_exists($value['id'], $stock_list)) {
             $stock_list[$value['id']] = 0;
         }
         if ($value['daycount'] - $stock_list[$value['id']] - $value['count'] < 0) {
             $this->message($valeu['name'] . '库存不足');
             exit;
         }
     }
     $ip_l = new iplocation();
     $ipaddress = $ip_l->getaddress($ip_l->getIP());
     if (isset($ipaddress["area1"])) {
         $info['ipaddress'] = $ipaddress['ip'] . mb_convert_encoding($ipaddress["area1"], 'UTF-8', 'GB2312');
         //('GB2312','ansi',);
     }
     //area1 二级地址名称	area2 三级地址名称	area3
     $nowID = intval(ICookie::get('myaddress'));
     if (!empty($nowid)) {
         if (empty($nowID)) {
             $this->message('未选择配送区域');
         }
         $checkareaid = $nowID;
         $dataareaids = array();
         while ($checkareaid > 0) {
             $temp_check = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id ='" . $checkareaid . "'   order by id desc limit 0,50");
             if (empty($temp_check)) {
                 break;
             }
             if (in_array($checkareaid, $dataareaids)) {
                 break;
             }
             $dataareaids[] = $checkareaid;
             $checkareaid = $temp_check['parent_id'];
         }
         $data['areaids'] = join(',', $dataareaids);
     } else {
         $data['areaids'] = '';
     }
     $checksend = Mysite::$app->config['ordercheckphone'];
     if ($checksend == 1) {
         if (empty($this->member['uid'])) {
             $checkphone = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "mobile where phone ='" . $info['mobile'] . "'   order by addtime desc limit 0,50");
             if (empty($checkphone)) {
                 $this->message('短信验证码不能为空');
             }
             if (empty($checkphone['is_send'])) {
                 $mycode = IFilter::act(IReq::get('phonecode'));
                 if ($mycode == $checkphone['code']) {
                     $this->mysql->update(Mysite::$app->config['tablepre'] . 'mobile', array('is_send' => 1), "phone='" . $info['mobile'] . "'");
                 } else {
                     $this->message('验证码不一致');
                 }
             }
         }
     }
     $data['shopcost'] = 0;
     //:店铺商品总价
     $data['shopps'] = 0;
     //店铺配送费
     $data['shoptype'] = 0;
     //: 0:普通订单,1订台订单
     $data['bagcost'] = 0;
     //:打包费
     //获取店铺商品总价  获取超市商品总价
     $data['shopcost'] = $carinfo['list'][$info['shopid']]['sum'];
     $data['shopps'] = $checkps['pscost'];
     $data['bagcost'] = $carinfo['list'][$info['shopid']]['bagcost'];
     //支付方式检测
     $userid = $info['userid'];
     $data['paytype'] = $info['paytype'];
     $paytype = $info['paytype'];
     if ($paytype != 'outpay') {
         if ($paytype == 'open_acout') {
             if (Mysite::$app->config['open_acout'] != 1 || $userid == 0) {
                 $data['paytype'] = 'outpay';
             }
         } else {
             $paylist = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "paylist where loginname='" . $paytype . "'  order by id desc  ");
             if ($paylist < 1) {
                 $data['paytype'] = 'outpay';
             }
         }
     }
     //判断促销
     $data['cxids'] = '';
     $data['cxcost'] = 0;
     $zpin = array();
     $cattype = $info['cattype'];
     if ($data['shopcost'] > 0) {
         $sellrule = new sellrule();
         $sellrule->setdata($info['shopid'], $data['shopcost'], $shopinfo['shoptype'], $day);
         $ruleinfo = $sellrule->getdata();
         $data['cxcost'] = $ruleinfo['downcost'];
         $data['cxids'] = $ruleinfo['cxids'];
         $zpin = $ruleinfo['zid'];
         //赠品
         $data['shopps'] = $ruleinfo['nops'] == true ? 0 : $data['shopps'];
     }
     //判断优惠劵
     $allcost = $data['shopcost'];
     $data['yhjcost'] = 0;
     $data['yhjids'] = '';
     $juanid = $info['juanid'];
     if ($juanid > 0 && $userid > 0) {
         $juaninfo = $this->mysql->select_one("select *  from " . Mysite::$app->config['tablepre'] . "juan  where id= '" . $juanid . "' and uid='" . $userid . "'  and status = 1 and endtime > " . time() . " ");
         if (!empty($juaninfo)) {
             if ($allcost >= $juaninfo['limitcost']) {
                 $data['yhjcost'] = $juaninfo['cost'];
                 $juandata['status'] = 2;
                 $juandata['usetime'] = time();
                 $this->mysql->update(Mysite::$app->config['tablepre'] . 'juan', $juandata, "id='" . $juanid . "'");
                 $data['yhjids'] = $juanid;
             }
         }
     }
     //积分抵扣
     $allcost = $allcost - $data['cxcost'] - $data['yhjcost'];
     $data['scoredown'] = 0;
     $dikou = $info['dikou'];
     if (!empty($userid) && $dikou > 0 && Mysite::$app->config['scoretocost'] > 0 && $allcost > $dikou) {
         $checkuser = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $userid . "'  ");
         if (is_array($checkuser)) {
             $checkscore = $dikou * intval(Mysite::$app->config['scoretocost']);
             if ($checkuser['score'] >= $checkscore) {
                 $data['scoredown'] = $checkscore;
                 $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`score`=`score`-' . $checkscore, "uid ='" . $userid . "' ");
             }
         }
     }
     $dikou = $data['scoredown'] > 0 ? $dikou : 0;
     $allcost = $allcost - $dikou;
     $data['allcost'] = $allcost + $data['shopps'] + $data['bagcost'];
     //订单应收费用
     $data['shopuid'] = 0;
     // 店铺UID
     $data['shopid'] = 0;
     //店铺ID
     $data['shopname'] = '商城';
     //店铺名称
     $data['shopphone'] = Mysite::$app->config['marketphone'];
     //店铺电话
     $data['shopaddress'] = '';
     // 店铺地址
     $data['pstype'] = $checkps['pstype'];
     $data['shoptype'] = $shopinfo['shoptype'];
     //检测店铺
     $settime = time() - 600;
     if ($settime > $nowpost) {
         $this->message('提交配送时间和服务器时间相差超过10分钟下单失败');
     }
     $temp = strtotime($minit . ':00');
     $is_orderbefore = $shopinfo['is_orderbefore'] == 0 ? 0 : $shopinfo['befortime'];
     $tempinfo = $this->checkshopopentime($is_orderbefore, $nowpost, $shopinfo['starttime']);
     if (!$tempinfo) {
         $this->message('配送时间不在有效配送时间范围');
     }
     if ($shopinfo['is_open'] != 1) {
         $this->message('店铺暂停营业');
     }
     if ($shopinfo['limitcost'] > $allcost) {
         $this->message('商品总价低于最小起送价' . $shopinfo['limitcost']);
     }
     $data['shopuid'] = $shopinfo['uid'];
     // 店铺UID
     $data['shopid'] = $shopinfo['id'];
     //店铺ID
     $data['shopname'] = $shopinfo['shopname'];
     //店铺名称
     $data['shopphone'] = $shopinfo['phone'];
     //店铺电话
     $data['shopaddress'] = $shopinfo['address'];
     // 店铺地址
     $data['buyeraddress'] = $info['addressdet'];
     $data['ordertype'] = $info['ordertype'];
     //来源方式;
     $data['buyeruid'] = $userid;
     // 购买用户ID,0未注册用户
     $data['buyername'] = $info['username'];
     //购买热名称
     $data['buyerphone'] = $info['mobile'];
     // 联系电话
     $panduan = Mysite::$app->config['man_ispass'];
     $data['status'] = $panduan == 1 ? '0' : 1;
     $data['paystatus'] = 0;
     // 支付状态1已支付
     $data['content'] = $info['remark'];
     // 订单备注
     //  daycode 当天订单序号
     $data['ipaddress'] = $info['ipaddress'];
     $data['is_ping'] = 0;
     // 是否评价字段 1已评完 0未评
     $data['addtime'] = time();
     $data['posttime'] = $nowpost;
     //: 配送时间
     $data['othertext'] = $info['othercontent'];
     //其他说明
     $data['is_make'] = Mysite::$app->config['allowed_is_make'] == 1 ? 0 : 1;
     //  :审核时间
     $data['passtime'] = time();
     if ($data['status'] == 1) {
         $data['passtime'] == 0;
     }
     $data['buycode'] = substr(md5(time()), 9, 6);
     $data['dno'] = time() . rand(1000, 9999);
     $minitime = strtotime(date('Y-m-d', time()));
     $tj = $this->mysql->select_one("select count(id) as shuliang from " . Mysite::$app->config['tablepre'] . "order where shopid='" . $info['shopid'] . "' and addtime > " . $minitime . "  limit 0,1000");
     $data['daycode'] = $tj['shuliang'] + 1;
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'order', $data);
     //写主订单
     $orderid = $this->mysql->insertid();
     $this->orderid = $orderid;
     foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) {
         $cmd['order_id'] = $orderid;
         $cmd['goodsid'] = $value['id'];
         $cmd['goodsname'] = $value['name'];
         $cmd['goodscost'] = $value['cost'];
         $cmd['goodscount'] = $value['count'];
         $cmd['shopid'] = $value['shopid'];
         $cmd['status'] = 0;
         $cmd['is_send'] = 0;
         $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $cmd);
         //减少库存pinkky
         $daystock = $this->mysql->select_one("SELECT * FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id=" . $value['id'] . " and day=" . $day);
         if ($daystock) {
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'daystock', '`stock`=`stock`+1', "id=" . $daystock['id']);
         } else {
             $stockdata['goods_id'] = $value['id'];
             $stockdata['day'] = $day;
             $stockdata['stock'] = 1;
             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'daystock', $stockdata);
         }
         //$this->mysql->update(Mysite::$app->config['tablepre'].'goods','`count`=`count`-'.$cmd['goodscount'].' ,`sellcount`=`sellcount`+'.$cmd['goodscount'],"id='".$cmd['goodsid']."'");
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', '`sellcount`=`sellcount`+' . $cmd['goodscount'], "id='" . $cmd['goodsid'] . "'");
     }
     if (is_array($zpin) && count($zpin) > 0) {
         foreach ($zpin as $key => $value) {
             $datadet['order_id'] = $orderid;
             $datadet['goodsid'] = $key;
             $datadet['goodsname'] = $value['presenttitle'];
             $datadet['goodscost'] = 0;
             $datadet['goodscount'] = 1;
             $datadet['shopid'] = $shopinfo['id'];
             $datadet['status'] = 0;
             $datadet['is_send'] = 1;
             //更新促销规则中 此赠品的数量
             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $datadet);
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'rule', '`controlcontent`=`controlcontent`-1', "id='" . $key . "'");
         }
     }
     $checkbuyer = Mysite::$app->config['allowedsendbuyer'];
     $checksend = Mysite::$app->config['man_ispass'];
     if ($checksend != 1) {
         $orderCLs = new orderclass($this->mysql);
         $orderCLs->sendmess($orderid);
     }
     if ($userid == 0) {
         ICookie::set('orderid', $orderid, 86400);
     } else {
         //保持地址数据
         $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "address where userid='" . $userid . "'  ");
         if (empty($checkinfo)) {
             $addata['userid'] = $this->member['uid'];
             $addata['username'] = $this->member['username'];
             $addata['address'] = $data['buyeraddress'];
             $addata['phone'] = $data['buyerphone'];
             $addata['contactname'] = $data['buyername'];
             $addata['default'] = 1;
             $this->mysql->insert(Mysite::$app->config['tablepre'] . 'address', $addata);
         }
     }
     $Cart->delshop($info['shopid']);
     $this->success($orderid);
 }
Esempio n. 4
0
 /**
  * 保存日志信息
  */
 public function actionsavelog()
 {
     $access_key = '';
     $secret_key = '';
     $log_string = '';
     $domain = '';
     $rand = md5(date("Y-m-d H:i:s"));
     if (Yii::app()->request->getParam('access_key')) {
         $access_key = Yii::app()->request->getParam('access_key');
     }
     if (Yii::app()->request->getParam('secret_key')) {
         $secret_key = Yii::app()->request->getParam('secret_key');
     }
     if (empty($access_key) || empty($secret_key)) {
         echo "验证失败";
         exit;
     }
     $brand_obj = Yii::app()->db->createCommand()->select('brandid,domain')->from('erp_qiniu_account')->where('access_key=:access_key and secret_key=:secret_key', array(':access_key' => $access_key, ':secret_key' => $secret_key))->queryRow();
     if (empty($brand_obj)) {
         echo '没有对应的品牌数据';
         exit;
     }
     $domain = $brand_obj['domain'];
     $logurl = $domain . "log/op.log?" . $rand;
     $log_string = file_get_contents($logurl);
     $brand_id = $brand_obj['brandid'];
     //品牌ID号
     //获取品牌 SKU 规则
     $brand_ret = Brand::brandSelectById($brand_id);
     if (count($brand_ret) == 0) {
         throw new Exception('');
     }
     $code_start = $brand_ret[0]['code_start'];
     $code_end = $brand_ret[0]['code_end'];
     if (empty($log_string)) {
         echo "log data fail";
         exit;
     }
     //		$command = Yii::app()->db->createCommand();
     //		$array = array ("orderlog" =>$log_string, "addtime" => date('Y-m-d H:i:s'), "orderid" => $brand_id);
     //		$command->insert('erp_orderlog', $array);
     //		exit();
     //		$log_string='ok|orderlist/z004X001/115230C211261/model/UQ15002441_B_100.jpg|2015-11-06 12:12:12
     //ok|orderlist/z004X001/115230C2112/115230C211261/model/UQ15002441_B_101.jpg|2015-11-06 12:12:12
     //fail|orderlist/z004X001/115250C0327/115250C032734/model/UQ15002441_B_102.jpg|2015-11-06 12:12:12
     //fail|orderlist/z004X002/115230E3211/115230E321115/product/UQ15002441_A0_101.jpg|2015-11-06 12:12:12
     //ok|orderlist/z004X003/115220A6205/115220A620517/product/UQ15002441_A2_101.jpg|2015-11-06 12:12:12
     //ok|poster/15ss/dscn001.jpg|2015-11-06 12:12:12
     //ok|poster/14ss/dscn002.jpg|2015-11-06 12:12:12';
     $log_array = explode("\n", $log_string);
     //按回车进行分隔,日志数组
     $log_array = array_filter($log_array);
     $order_array = array();
     //订单数组
     $brandnumber_array = array();
     //款号数组
     $order_name_array = array();
     //订单名数组
     $poster_array = array();
     //海报数组
     foreach ($log_array as $value) {
         $string_array = explode(" | ", $value);
         //按"|"进行分隔,得到(状态|路径|时间)
         if (count($string_array) > 0) {
             $geshi_array = array();
             //格式数组
             $geshi_array['url'] = '';
             //路径
             if ($string_array[0] == 'ok' || $string_array[0] == 'fail') {
                 $url_array = array();
                 //路径数组
                 $geshi_array['status'] = $string_array[0];
                 //状态
                 $geshi_array['date'] = $string_array[2];
                 //时间
                 if (!empty($string_array[1])) {
                     $geshi_array['url'] = $string_array[1];
                     //路径
                     $url_array = explode("/", $string_array[1]);
                     //将url路径分隔为数组
                     if (count($url_array) == 6) {
                         $order_array[$url_array[1]][] = $geshi_array;
                         $brandnumber_array[$url_array[3]][] = $geshi_array;
                         if (!in_array($url_array[1], $order_name_array)) {
                             $order_name_array[] = $url_array[1];
                             //订单名数组
                         }
                     }
                     if (count($url_array) == 3) {
                         $poster_array[$url_array[1]][] = $geshi_array;
                         //海报数据数组
                     }
                 }
             }
         }
     }
     /***************海报****************开始**************/
     $key_string = '';
     $poster_image_obj = array();
     $image_obj_count = 0;
     if (count($poster_array) > 0) {
         //查询一个款号下的所有的图片url
         $poster_image_obj = Yii::app()->db->createCommand()->select('url')->from('erp_poster')->where("brandid={$brand_id}")->queryAll();
         $image_obj_count = count($image_obj);
     }
     foreach ($poster_array as $key => $value) {
         if ($key != $key_string) {
             foreach ($poster_array[$key] as $poster_array_value) {
                 if ($poster_array_value['status'] == 'ok') {
                     $ishave = false;
                     //默认数据库中不存在
                     foreach ($poster_image_obj as $poster_image_obj_value) {
                         if ($poster_image_obj_value['url'] == $poster_array_value['url']) {
                             $ishave = true;
                         }
                     }
                     if ($ishave == false) {
                         $image_name = '';
                         //图片名字
                         $image_url = explode("/", $poster_array_value['url']);
                         if (count($image_url) > 0) {
                             $image_name = $image_url[count($image_url) - 1];
                         }
                         $array = array("name" => $image_name, "url" => $poster_array_value['url'], "addtime" => $poster_array_value['date'], "brandid" => $brand_id, "status" => 0, "dirname" => $key);
                         $erp_image = Yii::app()->db->createCommand();
                         $erp_image->insert('erp_poster', $array);
                     }
                 }
             }
         }
     }
     /***************海报****************结束**************/
     $order_name_obj = array();
     if (count($order_name_array) > 0) {
         //获取所有需要的订单的ID号
         $order_name_obj = orderclass::select_order_id($brand_id, $order_name_array);
     }
     /***************订单日志表****************开始**************/
     $key_string = '';
     foreach ($order_array as $key => $value) {
         if ($key != $key_string) {
             $log_show_string = '';
             $key_string = $key;
             $success_pnum = 0;
             //成功产品图数量
             $success_mnum = 0;
             //成功模特图数量
             $success_dnum = 0;
             //成功细节图数量
             $fail_pnum = 0;
             //失败产品图数量
             $fail_mnum = 0;
             //失败模特图数量
             $fail_dnum = 0;
             //失败细节图数量
             $success_url = '';
             //成功的图片url
             $fail_url = '';
             //失败的图片url
             $date = date("Y-m-d H:i:s");
             foreach ($order_array[$key] as $order_value) {
                 $date = $order_value['date'];
                 if ($order_value['status'] == 'ok') {
                     if (strpos($order_value['url'], 'product')) {
                         $success_pnum++;
                     } else {
                         if (strpos($order_value['url'], 'model')) {
                             $success_mnum++;
                         } else {
                             if (strpos($order_value['url'], 'details')) {
                                 $success_dnum++;
                             }
                         }
                     }
                     $success_url .= $order_value['url'] . "<br>";
                 }
             }
             $log_show_string .= "时间:" . $date . "<br>";
             $log_show_string .= "产品图:成功" . $success_pnum . "张;模特图:成功" . $success_mnum . "张;细节图:成功" . $success_dnum . "张" . "<br>";
             $log_show_string .= "详情:" . "<br>";
             $log_show_string .= "成功图片列表:" . "<br>";
             $log_show_string .= $success_url . "<br>";
             $orderobj = Yii::app()->db->createCommand()->select('id')->from('erp_order')->where("ordername='" . $key . "'")->queryRow();
             if (!empty($orderobj)) {
                 $command = Yii::app()->db->createCommand();
                 $array = array("orderlog" => $log_show_string, "addtime" => $date, "orderid" => $orderobj['id']);
                 $command->insert('erp_orderlog', $array);
             }
         }
     }
     /***************订单日志表****************结束**************/
     /***************订单衣服表****************开始**************/
     //通过款号录入衣服信息
     $key_string = '';
     $clothesorder = new clothesorderclass();
     foreach ($brandnumber_array as $key => $value) {
         if ($key != $key_string) {
             $order_obj = array();
             //款号所属的订单数
             //查询是否录入过此款号
             $brand_obj = Yii::app()->db->createCommand()->select('id')->from('erp_clothes_order')->where("brandnumber='" . $key . "' and brandid={$brand_id} and status=0")->queryRow();
             if (empty($brand_obj)) {
                 $orderid = 0;
                 if (count($order_name_obj) > 0) {
                     foreach ($brandnumber_array[$key] as $brandnumber_value) {
                         $image_url = explode("/", $brandnumber_value['url']);
                         $order_name = $image_url[1];
                         foreach ($order_name_obj as $order_name_obj_value) {
                             if ($order_name == $order_name_obj_value['ordername']) {
                                 $orderid = $order_name_obj_value['id'];
                                 break;
                             }
                         }
                         break;
                     }
                 }
                 //将SKC转为SKU
                 $brandnumber_SKU = $key;
                 if ($code_start != 0 || $code_end != 0) {
                     //设置了款号规则后 按规则提取款号
                     $brandnumber_SKU = $this->SKCToSKU($code_start, $code_end, $key);
                 }
                 $clothes_order_id = $clothesorder->create_erp_clothes($brandnumber_SKU, $key, $orderid, $brand_id);
                 /*$array = array ("sku"=>$brandnumber_SKU,"brandnumber" =>$key, "pcount" => 0, 
                 		"mcount" => 0,"dcount" => 0,"description" => '',
                 		"orderid" => $orderid,"brandcategoryid" => 0,"addtime" => date("Y-m-d H:i:s"),
                 		"brandid" => $brand_id,"status" => 0);
                 		$command = Yii::app()->db->createCommand();
                 		$command->insert('erp_clothes_order', $array);
                 		$clothes_order_id= Yii::app()->db->getLastInsertID();
                 		*/
                 $clothes_image_array = array("clothes_order_id" => $clothes_order_id, "tablename" => "erp_image");
                 $erp_clothes_image = Yii::app()->db->createCommand();
                 $erp_clothes_image->insert('erp_clothes_image', $clothes_image_array);
             } else {
                 $clothes_order_id = $brand_obj['id'];
             }
             //查询一个款号下的所有的图片url
             $image_obj = Yii::app()->db->createCommand()->select('url,type')->from('erp_image')->where("clothes_order_id={$clothes_order_id} and isshow=0")->queryAll();
             $image_obj_count = count($image_obj);
             foreach ($brandnumber_array[$key] as $brandnumber_value) {
                 if ($brandnumber_value['status'] == 'ok') {
                     $ishave = false;
                     //默认数据库中不存在
                     if ($image_obj_count > 0) {
                         foreach ($image_obj as $image_obj_value) {
                             //找到相同的url了
                             if ($image_obj_value['url'] == $brandnumber_value['url']) {
                                 $ishave = true;
                                 break;
                             }
                         }
                     }
                     if ($ishave == false) {
                         $image_name = '';
                         //图片名字
                         $image_url = explode("/", $brandnumber_value['url']);
                         if (count($image_url) > 0) {
                             $image_name = $image_url[count($image_url) - 1];
                             //								if(strpos($image_name,'.'))
                             //								{
                             //									$name=explode(".",$image_name);
                             //									$image_name=$name[0];
                             //								}
                         }
                         //A图、B模特图、C细节图、D海报图
                         $type = 1;
                         //默认为产品图
                         if (strpos($brandnumber_value['url'], 'model')) {
                             $type = 3;
                         } else {
                             if (strpos($brandnumber_value['url'], 'details')) {
                                 $type = 4;
                             }
                         }
                         $array = array("name" => $image_name, "status" => 0, "addtime" => $brandnumber_value['date'], "updatetime" => $brandnumber_value['date'], "istop" => 0, "type" => $type, "url" => $brandnumber_value['url'], "isshow" => 0, "isback" => 0, "clothes_order_id" => $clothes_order_id);
                         $erp_image = Yii::app()->db->createCommand();
                         $erp_image->insert('erp_image', $array);
                     }
                 }
             }
         }
     }
     /***************订单衣服表****************结束**************/
     echo "success";
     exit;
 }
Esempio n. 5
0
 public function makeorder()
 {
     $subtype = intval(IReq::get("subtype"));
     $info['shopid'] = intval(IReq::get("shopid"));
     $info['remark'] = IFilter::act(IReq::get("content"));
     $info['paytype'] = IFilter::act(IReq::get("paytype"));
     $info['username'] = IFilter::act(IReq::get("contactname"));
     $info['mobile'] = IFilter::act(IReq::get("phone"));
     $info['addressdet'] = IFilter::act(IReq::get("addressdet"));
     $info['senddate'] = IFilter::act(IReq::get("senddate"));
     $info['minit'] = IFilter::act(IReq::get("orderTime"));
     $info['juanid'] = intval(IReq::get("juanid"));
     $info['ordertype'] = 1;
     $peopleNum = IFilter::act(IReq::get("personcount"));
     $info['othercontent'] = empty($peopleNum) ? "" : serialize(array("人数" => $peopleNum));
     $info['userid'] = !isset($this->member['score']) ? "0" : $this->member['uid'];
     if (Mysite::$app->config['allowedguestbuy'] != 1 && $info['userid'] == 0) {
         $this->message("member_nologin");
     }
     $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     if (empty($shopinfo)) {
         $this->message("店铺不存在");
     }
     $checksend = Mysite::$app->config['ordercheckphone'];
     if ($checksend == 1 && empty($this->member['uid'])) {
         $checkphone = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "mobile where phone ='" . $info['mobile'] . "'   order by addtime desc limit 0,50");
         if (empty($checkphone)) {
             $this->message("member_emailyan");
         }
         if (empty($checkphone['is_send'])) {
             $mycode = IFilter::act(IReq::get("phonecode"));
             if ($mycode == $checkphone['code']) {
                 $this->mysql->update(Mysite::$app->config['tablepre'] . "mobile", array("is_send" => 1), "phone='" . $info['mobile'] . "'");
             } else {
                 $this->message("member_emailyan");
             }
         }
     }
     if (empty($info['username'])) {
         $this->message("emptycontact");
     }
     if (!IValidate::suremobi($info['mobile'])) {
         $this->message("errphone");
     }
     $info['ipaddress'] = "";
     $ip_l = new iplocation();
     $ipaddress = $ip_l->getaddress($ip_l->getIP());
     if (isset($ipaddress['area1'])) {
         $info['ipaddress'] = $ipaddress['ip'] . mb_convert_encoding($ipaddress['area1'], "UTF-8", "GB2312");
     }
     $info['cattype'] = 0;
     $senddate = $info['senddate'];
     $minit = $info['minit'];
     $nowpost = strtotime($senddate . " " . $minit . ":00");
     $settime = time() - 600;
     if ($nowpost < $settime) {
         $this->message("提交配送时间和服务器时间相差超过10分钟下单失败");
     }
     $temp = strtotime($minit . ":00");
     $is_orderbefore = $shopinfo['is_orderbefore'] == 0 ? 0 : $shopinfo['befortime'];
     $tempinfo = $this->checkshopopentime($is_orderbefore, $nowpost, $shopinfo['starttime']);
     if (!$tempinfo) {
         $this->message("配送时间不在有效配送时间范围");
     }
     if ($shopinfo['is_open'] != 1) {
         $this->message("店铺暂停营业");
     }
     $info['paytype'] = $info['paytype'] == 1 ? 1 : 0;
     $info['areaids'] = "";
     $info['shopinfo'] = $shopinfo;
     if ($subtype == 1) {
         $info['allcost'] = 0;
         $info['bagcost'] = 0;
         $info['allcount'] = 0;
         $info['goodslist'] = array();
     } else {
         if (empty($info['shopid'])) {
             $this->message("shop_noexit");
         }
         $Cart = new smCart();
         $Cart->cartName = 'platesmcart';
         $carinfo = $Cart->getMyCart();
         if (!isset($carinfo['list'][$info['shopid']]['data'])) {
             $this->message("shop_emptycart");
         }
         $info['allcost'] = $carinfo['list'][$info['shopid']]['sum'];
         $info['goodslist'] = $carinfo['list'][$info['shopid']]['data'];
         $info['bagcost'] = 0;
         $info['allcount'] = 0;
     }
     $info['shopps'] = 0;
     $info['pstype'] = 0;
     $info['cattype'] = 1;
     $info['is_goshop'] = 1;
     $info['subtype'] = $subtype;
     $info['sendtime'] = $nowpost;
     $orderclass = new orderclass($this->mysql);
     $orderclass->orderyuding($info);
     $orderid = $orderclass->getorder();
     if ($info['userid'] == 0) {
         ICookie::set("orderid", $orderid, 86400);
     }
     if ($subtype == 2) {
         $Cart->delshop($info['shopid']);
     }
     $this->success($orderid);
     exit;
 }
Esempio n. 6
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;
     }
 }