diff --git a/application/admin/controller/order/combinationOrder.php b/application/admin/controller/order/combinationOrder.php index 495b0767..48b2afe1 100644 --- a/application/admin/controller/order/combinationOrder.php +++ b/application/admin/controller/order/combinationOrder.php @@ -1 +1,583 @@ -request); $limitTimeList = [ 'yesterday'=>implode(' - ',[date('Y/m/d',strtotime('-1 day')),date('Y/m/d')]), 'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]), 'week'=>implode(' - ',[ date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) ]), 'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]), 'quarter'=>implode(' - ',[ date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01', date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y'))) ]), 'year'=>implode(' - ',[ date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day')) ]) ]; $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); $this->assign('price',StoreOrderModel::getOrderPrice($where)); $this->assign(compact('where','limitTimeList')); return $this->fetch(); } public function orderchart(){ $where = Util::getMore([ ['status',''], ['real_name',''], ['is_del',0], ['data',''], ['combination_id',''], ['export',0], ['order','id desc'] ],$this->request); $limitTimeList = [ 'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]), 'week'=>implode(' - ',[ date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) ]), 'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]), 'quarter'=>implode(' - ',[ date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01', date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y'))) ]), 'year'=>implode(' - ',[ date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day')) ]) ]; if($where['data'] == '') $where['data'] = $limitTimeList['today']; $orderCount = [ urlencode('未支付')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(0))->count(), urlencode('未发货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(1))->count(), urlencode('待收货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(2))->count(), urlencode('待评价')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(3))->count(), urlencode('交易完成')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(4))->count(), urlencode('退款中')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-1))->count(), urlencode('已退款')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-2))->count() ]; $model = StoreOrderModel::getOrderWhere($where,new StoreOrderModel())->field('sum(total_num) total_num,count(*) count,sum(total_price) total_price,sum(refund_price) refund_price,from_unixtime(add_time,\'%Y-%m-%d\') add_time') ->group('from_unixtime(add_time,\'%Y-%m-%d\')'); $orderPrice = $model->select()->toArray(); $orderDays = []; $orderCategory = [ ['name'=>'商品数','type'=>'line','data'=>[]], ['name'=>'订单数','type'=>'line','data'=>[]], ['name'=>'订单金额','type'=>'line','data'=>[]], ['name'=>'退款金额','type'=>'line','data'=>[]] ]; foreach ($orderPrice as $price){ $orderDays[] = $price['add_time']; $orderCategory[0]['data'][] = $price['total_num']; $orderCategory[1]['data'][] = $price['count']; $orderCategory[2]['data'][] = $price['total_price']; $orderCategory[3]['data'][] = $price['refund_price']; } $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); $this->assign('price',StoreOrderModel::getOrderPrice($where)); $this->assign(compact('limitTimeList','where','orderCount','orderPrice','orderDays','orderCategory')); return $this->fetch(); } /** * 修改支付金额等 * @param $id * @return mixed|\think\response\Json|void */ public function edit($id) { if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $this->assign([ 'title'=>'修改订单','rules'=>$this->read($id)->getContent(), 'action'=>Url::build('update',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } public function read($id) { if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); Form::text('order_id','订单编号',$product->getData('order_id'))->readonly(); Form::number('total_price','商品总价',$product->getData('total_price'))->min(0); Form::number('total_postage','原始邮费',$product->getData('total_postage'))->min(0); Form::number('pay_price','实际支付金额',$product->getData('pay_price'))->min(0); Form::number('pay_postage','实际支付邮费',$product->getData('pay_postage'))->min(0); Form::number('gain_integral','赠送积分',$product->getData('gain_integral'))->min(0); return Form::builder(); } public function update(Request $request, $id) { $data = Util::postMore([ 'order_id', 'total_price', 'total_postage', 'pay_price', 'pay_postage', 'gain_integral', ],$request); if($data['total_price'] <= 0) return Json::fail('请输入商品总价'); if($data['pay_price'] <= 0) return Json::fail('请输入实际支付金额'); $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']); StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_edit',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'order_edit','修改商品总价为:'.$data['total_price'].' 实际支付金额'.$data['pay_price']); return Json::successful('修改成功!'); } /** * 送货 * @param $id * send */ public function delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0) { $this->assign([ 'title' => '送货信息', 'rules' => $this->readDelivery($id)->getContent(), 'action' => Url::build('updateDelivery', array('id' => $id)) ]); return $this->fetch('public/common_form'); } else return Json::fail('数据不存在!'); } public function readDelivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); Form::text('delivery_name','送货人姓名'); Form::text('delivery_id','送货人电话')->number(); return Form::builder(); } public function updateDelivery(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'send'; if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'delivery','已配送 发货人:'.$data['delivery_name'].' 发货人电话:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 发货 * @param $id * express */ public function deliver_goods($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1 && $product['status'] == 0){ $this->assign([ 'title'=>'发货信息','rules'=>$this->readDeliveryGoods($id)->getContent(), 'action'=>Url::build('updateDeliveryGoods',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } else return Json::fail('数据不存在!'); } public function readDeliveryGoods($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); Form::select('delivery_name','快递公司',function(){ $list = Db::name('express')->where('is_show',1)->order('sort DESC')->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; })->filterable(); Form::text('delivery_id','快递单号'); return Form::builder(); } public function updateDeliveryGoods(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); $data['delivery_type'] = 'express'; if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); $data['status'] = 1; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_delivery_goods',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'delivery_goods','已发货 快递公司:'.$data['delivery_name'].' 快递单号:'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改状态为已收货 * @param $id * @return \think\response\Json|void */ public function take_delivery($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['status'] == 2) return Json::fail('不能重复收货!'); if($product['paid'] == 1 && $product['status'] == 1) $data['status'] = 2; else if($product['pay_type'] == 'offline') $data['status'] = 2; else return Json::fail('请先发货或者送货!'); if(!StoreOrderModel::edit($data,$id)) return Json::fail(StoreOrderModel::getErrorInfo('收货失败,请稍候再试!')); else{ try{ HookService::listen('store_product_order_take_delivery',$data,$id,false,OrderBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'take_delivery','已收货'); return Json::successful('收货成功!'); } } /** * 修改退款状态 * @param $id * @return \think\response\Json|void */ public function refund_y($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $this->assign([ 'title'=>'退款','rules'=>$this->readRefundY($id)->getContent(), 'action'=>Url::build('updateRefundY',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } else return Json::fail('数据不存在!'); } public function readRefundY($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); Form::text('order_id','退款单号',$product->getData('order_id'))->readonly(); Form::number('refund_price','退款金额',$product->getData('pay_price'))->min(0); Form::radio('type','状态',[['label'=>'直接退款','value'=>1],['label'=>'退款后,返回原状态','value'=>2]],1); return Form::builder(); } public function updateRefundY(Request $request, $id){ $data = Util::postMore([ 'refund_price', ['type',1], ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了'); if(!$data['refund_price']) return Json::fail('请输入退款金额'); $refund_price = $data['refund_price']; $data['refund_price'] = bcadd($data['refund_price'],$product['refund_price'],2); $bj = bccomp((float)$product['pay_price'],(float)$data['refund_price'],2); if($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额'); if($data['type'] == 1){ $data['refund_status'] = 2; }else if($data['type'] == 2){ $data['refund_status'] = 0; } $type = $data['type']; unset($data['type']); $refund_data['pay_price'] = $product['pay_price']; $refund_data['refund_price'] = $refund_price; if($product['pay_type'] == 'weixin'){ try{ HookService::listen('wechat_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); }catch(\Exception $e){ return Json::fail($e->getMessage()); } }else if($product['pay_type'] == 'yue'){ ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'now_money',$refund_price,'uid'); $res2 = $res2 = UserBill::income('商品退款',$product['uid'],'now_money','pay_product_refund',$refund_price,$product['id'],$product['pay_price'],'订单退款到余额'.floatval($refund_price).'元'); try{ HookService::listen('store_order_yue_refund',$product,$refund_data,false,OrderBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('余额退款失败!'); } $resEdit = StoreOrderModel::edit($data,$id); if($resEdit){ $data['type'] = $type; if($data['type'] == 1) StorePink::setRefundPink($id); HookService::afterListen('store_product_order_refund_y',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元'); return Json::successful('修改成功!'); }else{ StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元失败'); return Json::successful('修改失败!'); } } public function order_info($oid = '') { if(!$oid || !($orderInfo = StoreOrderModel::get($oid))) return $this->failed('订单不存在!'); $userInfo = User::getUserInfo($orderInfo['uid']); if($userInfo['spread_uid']){ $spread = User::where('uid',$userInfo['spread_uid'])->value('nickname'); }else{ $spread =''; } $this->assign(compact('orderInfo','userInfo','spread')); return $this->fetch(); } public function express($oid = '') { if(!$oid || !($order = StoreOrderModel::get($oid))) return $this->failed('订单不存在!'); if($order['delivery_type'] != 'express' || !$order['delivery_id']) return $this->failed('该订单不存在快递单号!'); $cacheName = $order['order_id'].$order['delivery_id']; $result = CacheService::get($cacheName,null); if($result === null){ $result = Express::query($order['delivery_id']); if(is_array($result) && isset($result['result']) && isset($result['result']['deliverystatus']) && $result['result']['deliverystatus'] >= 3) $cacheTime = 0; else $cacheTime = 1800; CacheService::set($cacheName,$result,$cacheTime); } $this->assign([ 'order'=>$order, 'express'=>$result ]); return $this->fetch(); } /** * 修改配送信息 * @param $id * @return mixed|\think\response\Json|void */ public function distribution($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $this->assign([ 'title'=>'配送信息','rules'=>$this->readDistribution($id)->getContent(), 'action'=>Url::build('updateDistribution',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } public function readDistribution($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['delivery_type'] == 'send'){ Form::text('delivery_name','送货人姓名',$product->getData('delivery_name')); Form::text('delivery_id','送货人电话',$product->getData('delivery_id'))->number(); }else if($product['delivery_type'] == 'express'){ Form::select('delivery_name','快递公司',function(){ $list = Db::name('express')->where('is_show',1)->column('id,name'); $menus = []; foreach ($list as $k=>$v){ $menus[] = ['value'=>$v,'label'=>$v]; } return $menus; },$product->getData('delivery_name'))->filterable(); Form::text('delivery_id','快递单号',$product->getData('delivery_id')); } return Form::builder(); } public function updateDistribution(Request $request, $id){ $data = Util::postMore([ 'delivery_name', 'delivery_id', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['delivery_type'] == 'send'){ if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); }else if($product['delivery_type'] == 'express'){ if(!$data['delivery_name']) return Json::fail('请选择快递公司'); if(!$data['delivery_id']) return Json::fail('请输入快递单号'); } StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_distribution',$data,$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'distribution','修改发货信息为'.$data['delivery_name'].'号'.$data['delivery_id']); return Json::successful('修改成功!'); } /** * 修改退款状态 * @param $id * @return mixed|\think\response\Json|void */ public function refund_n($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); $this->assign([ 'title'=>'退款','rules'=>$this->readRefundN($id)->getContent(), 'action'=>Url::build('updateRefundN',array('id'=>$id)) ]); return $this->fetch('public/common_form'); } public function readRefundN($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); Form::text('order_id','退款单号',$product->getData('order_id'))->readonly(); Form::textarea('refund_reason','退款原因'); return Form::builder(); } public function updateRefundN(Request $request, $id){ $data = Util::postMore([ 'refund_reason', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if(!$data['refund_reason']) return Json::fail('请输入退款原因'); $data['refund_status'] = 0; StoreOrderModel::edit($data,$id); HookService::afterListen('store_product_order_refund_n',$data['refund_reason'],$id,false,OrderBehavior::class); StoreOrderStatus::setStatus($id,'refund_n','不退款原因:'.$data['refund_reason']); return Json::successful('修改成功!'); } /** * 立即支付 * @param $id */ public function offline($id){ $res = StoreOrderModel::updateOffline($id); if($res){ try{ HookService::listen('store_product_order_offline',$id,false,OrderBehavior::class); }catch (Exception $e){ return Json::fail($e->getMessage()); } StoreOrderStatus::setStatus($id,'offline','线下付款'); return Json::successful('修改成功!'); }else{ return Json::fail('修改失败!'); } } /** * 修改积分和金额 * @param $id * @return mixed|\think\response\Json|void */ public function integral_back($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($product['paid'] == 1){ $this->assign([ 'title'=>'退积分','rules'=>$this->readIntegralBack($id)->getContent(), 'action'=>Url::build('updateIntegralBack',array('id'=>$id)) ]); }else{ return Json::fail('参数错误!'); } return $this->fetch('public/common_form'); } public function readIntegralBack($id){ if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); Form::text('order_id','退积分单号',$product->getData('order_id'))->readonly(); Form::number('back_integral','退积分')->min(0); return Form::builder(); } public function updateIntegralBack(Request $request, $id){ $data = Util::postMore([ 'back_integral', ],$request); if(!$id) return $this->failed('数据不存在'); $product = StoreOrderModel::get($id); if(!$product) return Json::fail('数据不存在!'); if($data['back_integral'] <= 0) return Json::fail('请输入积分'); if($product['use_integral'] == $product['back_integral']) return Json::fail('已退完积分!不能再积分了'); $back_integral = $data['back_integral']; $data['back_integral'] = bcadd($data['back_integral'],$product['back_integral'],2); $bj = bccomp((float)$product['use_integral'],(float)$data['back_integral'],2); if($bj < 0) return Json::fail('退积分大于支付积分,请修改退积分'); ModelBasic::beginTrans(); $res1 = User::bcInc($product['uid'],'integral',$back_integral,'uid'); $res2 = UserBill::income('商品退积分',$product['uid'],'integral','pay_product_integral_back',$back_integral,$product['id'],$product['pay_price'],'订单退积分'.floatval($back_integral).'积分到用户积分'); try{ HookService::listen('store_order_integral_back',$product,$back_integral,false,OrderBehavior::class); }catch (\Exception $e){ ModelBasic::rollbackTrans(); return Json::fail($e->getMessage()); } $res = $res1 && $res2; ModelBasic::checkTrans($res); if(!$res) return Json::fail('退积分失败!'); StoreOrderModel::edit($data,$id); StoreOrderStatus::setStatus($id,'integral_back','商品退积分:'.$data['back_integral']); return Json::successful('退积分成功!'); } public function remark(Request $request){ $data = Util::postMore(['id','remark'],$request); if(!$data['id']) return Json::fail('参数错误!'); if($data['remark'] == '') return Json::fail('请输入要备注的内容!'); $id = $data['id']; unset($data['id']); StoreOrderModel::edit($data,$id); return Json::successful('备注成功!'); } public function order_status($oid){ if(!$oid) return $this->failed('数据不存在'); $this->assign(StoreOrderStatus::systemPage($oid)); return $this->fetch(); } } \ No newline at end of file +request); + $limitTimeList = [ + 'yesterday'=>implode(' - ',[date('Y/m/d',strtotime('-1 day')),date('Y/m/d')]), + 'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]), + 'week'=>implode(' - ',[ + date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), + date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) + ]), + 'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]), + 'quarter'=>implode(' - ',[ + date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01', + date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y'))) + ]), + 'year'=>implode(' - ',[ + date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day')) + ]) + ]; + $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); + $this->assign('price',StoreOrderModel::getOrderPrice($where)); + $this->assign(compact('where','limitTimeList')); + return $this->fetch(); + } + public function orderchart(){ + $where = Util::getMore([ + ['status',''], + ['real_name',''], + ['is_del',0], + ['data',''], + ['combination_id',''], + ['export',0], + ['order','id desc'] + ],$this->request); + $limitTimeList = [ + 'today'=>implode(' - ',[date('Y/m/d'),date('Y/m/d',strtotime('+1 day'))]), + 'week'=>implode(' - ',[ + date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), + date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) + ]), + 'month'=>implode(' - ',[date('Y/m').'/01',date('Y/m').'/'.date('t')]), + 'quarter'=>implode(' - ',[ + date('Y').'/'.(ceil((date('n'))/3)*3-3+1).'/01', + date('Y').'/'.(ceil((date('n'))/3)*3).'/'.date('t',mktime(0,0,0,(ceil((date('n'))/3)*3),1,date('Y'))) + ]), + 'year'=>implode(' - ',[ + date('Y').'/01/01',date('Y/m/d',strtotime(date('Y').'/01/01 + 1year -1 day')) + ]) + ]; + if($where['data'] == '') $where['data'] = $limitTimeList['today']; + $orderCount = [ + urlencode('未支付')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(0))->count(), + urlencode('未发货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(1))->count(), + urlencode('待收货')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(2))->count(), + urlencode('待评价')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(3))->count(), + urlencode('交易完成')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(4))->count(), + urlencode('退款中')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-1))->count(), + urlencode('已退款')=>StoreOrderModel::getOrderWhere($where,StoreOrderModel::statusByWhere(-2))->count() + ]; + $model = StoreOrderModel::getOrderWhere($where,new StoreOrderModel())->field('sum(total_num) total_num,count(*) count,sum(total_price) total_price,sum(refund_price) refund_price,from_unixtime(add_time,\'%Y-%m-%d\') add_time') + ->group('from_unixtime(add_time,\'%Y-%m-%d\')'); + $orderPrice = $model->select()->toArray(); + $orderDays = []; + $orderCategory = [ + ['name'=>'商品数','type'=>'line','data'=>[]], + ['name'=>'订单数','type'=>'line','data'=>[]], + ['name'=>'订单金额','type'=>'line','data'=>[]], + ['name'=>'退款金额','type'=>'line','data'=>[]] + ]; + foreach ($orderPrice as $price){ + $orderDays[] = $price['add_time']; + $orderCategory[0]['data'][] = $price['total_num']; + $orderCategory[1]['data'][] = $price['count']; + $orderCategory[2]['data'][] = $price['total_price']; + $orderCategory[3]['data'][] = $price['refund_price']; + } + $this->assign(StoreOrderModel::systemPage($where,$this->adminId)); + $this->assign('price',StoreOrderModel::getOrderPrice($where)); + $this->assign(compact('limitTimeList','where','orderCount','orderPrice','orderDays','orderCategory')); + return $this->fetch(); + } + /** + * 修改支付金额等 + * @param $id + * @return mixed|\think\response\Json|void + */ + public function edit($id) + { + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + $this->assign([ + 'title'=>'修改订单','rules'=>$this->read($id)->getContent(), + 'action'=>Url::build('update',array('id'=>$id)) + ]); + return $this->fetch('public/common_form'); + } + public function read($id) + { + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + Form::text('order_id','订单编号',$product->getData('order_id'))->readonly(); + Form::number('total_price','商品总价',$product->getData('total_price'))->min(0); + Form::number('total_postage','原始邮费',$product->getData('total_postage'))->min(0); + Form::number('pay_price','实际支付金额',$product->getData('pay_price'))->min(0); + Form::number('pay_postage','实际支付邮费',$product->getData('pay_postage'))->min(0); + Form::number('gain_integral','赠送积分',$product->getData('gain_integral'))->min(0); + return Form::builder(); + } + public function update(Request $request, $id) + { + $data = Util::postMore([ + 'order_id', + 'total_price', + 'total_postage', + 'pay_price', + 'pay_postage', + 'gain_integral', + ],$request); + if($data['total_price'] <= 0) return Json::fail('请输入商品总价'); + if($data['pay_price'] <= 0) return Json::fail('请输入实际支付金额'); + $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']); + StoreOrderModel::edit($data,$id); + HookService::afterListen('store_product_order_edit',$data,$id,false,OrderBehavior::class); + StoreOrderStatus::setStatus($id,'order_edit','修改商品总价为:'.$data['total_price'].' 实际支付金额'.$data['pay_price']); + return Json::successful('修改成功!'); + } + /** + * 送货 + * @param $id + * send + */ + public function delivery($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['paid'] == 1 && $product['status'] == 0) { + $this->assign([ + 'title' => '送货信息', 'rules' => $this->readDelivery($id)->getContent(), + 'action' => Url::build('updateDelivery', array('id' => $id)) + ]); + return $this->fetch('public/common_form'); + } + else return Json::fail('数据不存在!'); + } + public function readDelivery($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + Form::text('delivery_name','送货人姓名'); + Form::text('delivery_id','送货人电话')->number(); + return Form::builder(); + } + public function updateDelivery(Request $request, $id){ + $data = Util::postMore([ + 'delivery_name', + 'delivery_id', + ],$request); + $data['delivery_type'] = 'send'; + if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); + if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); + else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); + $data['status'] = 1; + StoreOrderModel::edit($data,$id); + HookService::afterListen('store_product_order_delivery',$data,$id,false,OrderBehavior::class); + StoreOrderStatus::setStatus($id,'delivery','已配送 发货人:'.$data['delivery_name'].' 发货人电话:'.$data['delivery_id']); + return Json::successful('修改成功!'); + } + /** + * 发货 + * @param $id + * express + */ + public function deliver_goods($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['paid'] == 1 && $product['status'] == 0){ + $this->assign([ + 'title'=>'发货信息','rules'=>$this->readDeliveryGoods($id)->getContent(), + 'action'=>Url::build('updateDeliveryGoods',array('id'=>$id)) + ]); + return $this->fetch('public/common_form'); + } + else return Json::fail('数据不存在!'); + } + public function readDeliveryGoods($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + Form::select('delivery_name','快递公司',function(){ + $list = Db::name('express')->where('is_show',1)->order('sort DESC')->column('id,name'); + $menus = []; + foreach ($list as $k=>$v){ + $menus[] = ['value'=>$v,'label'=>$v]; + } + return $menus; + })->filterable(); + Form::text('delivery_id','快递单号'); + return Form::builder(); + } + public function updateDeliveryGoods(Request $request, $id){ + $data = Util::postMore([ + 'delivery_name', + 'delivery_id', + ],$request); + $data['delivery_type'] = 'express'; + if(!$data['delivery_name']) return Json::fail('请选择快递公司'); + if(!$data['delivery_id']) return Json::fail('请输入快递单号'); + $data['status'] = 1; + StoreOrderModel::edit($data,$id); + HookService::afterListen('store_product_order_delivery_goods',$data,$id,false,OrderBehavior::class); + StoreOrderStatus::setStatus($id,'delivery_goods','已发货 快递公司:'.$data['delivery_name'].' 快递单号:'.$data['delivery_id']); + return Json::successful('修改成功!'); + } + /** + * 修改状态为已收货 + * @param $id + * @return \think\response\Json|void + */ + public function take_delivery($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['status'] == 2) return Json::fail('不能重复收货!'); + if($product['paid'] == 1 && $product['status'] == 1) $data['status'] = 2; + else if($product['pay_type'] == 'offline') $data['status'] = 2; + else return Json::fail('请先发货或者送货!'); + if(!StoreOrderModel::edit($data,$id)) + return Json::fail(StoreOrderModel::getErrorInfo('收货失败,请稍候再试!')); + else{ + try{ + HookService::listen('store_product_order_take_delivery',$data,$id,false,OrderBehavior::class); + }catch (Exception $e){ + return Json::fail($e->getMessage()); + } + StoreOrderStatus::setStatus($id,'take_delivery','已收货'); + return Json::successful('收货成功!'); + } + } + /** + * 修改退款状态 + * @param $id + * @return \think\response\Json|void + */ + public function refund_y($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['paid'] == 1){ + $this->assign([ + 'title'=>'退款','rules'=>$this->readRefundY($id)->getContent(), + 'action'=>Url::build('updateRefundY',array('id'=>$id)) + ]); + return $this->fetch('public/common_form'); + } + else return Json::fail('数据不存在!'); + } + public function readRefundY($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + Form::text('order_id','退款单号',$product->getData('order_id'))->readonly(); + Form::number('refund_price','退款金额',$product->getData('pay_price'))->min(0); + Form::radio('type','状态',[['label'=>'直接退款','value'=>1],['label'=>'退款后,返回原状态','value'=>2]],1); + return Form::builder(); + } + public function updateRefundY(Request $request, $id){ + $data = Util::postMore([ + 'refund_price', + ['type',1], + ],$request); + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了'); + if(!$data['refund_price']) return Json::fail('请输入退款金额'); + $refund_price = $data['refund_price']; + $data['refund_price'] = bcadd($data['refund_price'],$product['refund_price'],2); + $bj = bccomp((float)$product['pay_price'],(float)$data['refund_price'],2); + if($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额'); + if($data['type'] == 1){ + $data['refund_status'] = 2; + }else if($data['type'] == 2){ + $data['refund_status'] = 0; + } + $type = $data['type']; + unset($data['type']); + $refund_data['pay_price'] = $product['pay_price']; + $refund_data['refund_price'] = $refund_price; + if($product['pay_type'] == 'weixin'){ + try{ + HookService::listen('wechat_pay_order_refund',$product['order_id'],$refund_data,true,PaymentBehavior::class); + }catch(\Exception $e){ + return Json::fail($e->getMessage()); + } + }else if($product['pay_type'] == 'yue'){ + ModelBasic::beginTrans(); + $usermoney = User::where('uid',$product['uid'])->value('now_money'); + $res1 = User::bcInc($product['uid'],'now_money',$refund_price,'uid'); + $res2 = $res2 = UserBill::income('商品退款',$product['uid'],'now_money','pay_product_refund',$refund_price,$product['id'],bcadd($usermoney,$refund_price,2),'订单退款到余额'.floatval($refund_price).'元'); + try{ + HookService::listen('store_order_yue_refund',$product,$refund_data,false,OrderBehavior::class); + }catch (\Exception $e){ + ModelBasic::rollbackTrans(); + return Json::fail($e->getMessage()); + } + $res = $res1 && $res2; + ModelBasic::checkTrans($res); + if(!$res) return Json::fail('余额退款失败!'); + } + $resEdit = StoreOrderModel::edit($data,$id); + if($resEdit){ + $data['type'] = $type; + if($data['type'] == 1) StorePink::setRefundPink($id); + HookService::afterListen('store_product_order_refund_y',$data,$id,false,OrderBehavior::class); + StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元'); + return Json::successful('修改成功!'); + }else{ + StoreOrderStatus::setStatus($id,'refund_price','退款给用户'.$refund_price.'元失败'); + return Json::successful('修改失败!'); + } + } + public function order_info($oid = '') + { + if(!$oid || !($orderInfo = StoreOrderModel::get($oid))) + return $this->failed('订单不存在!'); + $userInfo = User::getUserInfo($orderInfo['uid']); + if($userInfo['spread_uid']){ + $spread = User::where('uid',$userInfo['spread_uid'])->value('nickname'); + }else{ + $spread =''; + } + $this->assign(compact('orderInfo','userInfo','spread')); + return $this->fetch(); + } + public function express($oid = '') + { + if(!$oid || !($order = StoreOrderModel::get($oid))) + return $this->failed('订单不存在!'); + if($order['delivery_type'] != 'express' || !$order['delivery_id']) return $this->failed('该订单不存在快递单号!'); + $cacheName = $order['order_id'].$order['delivery_id']; + $result = CacheService::get($cacheName,null); + if($result === null){ + $result = Express::query($order['delivery_id']); + if(is_array($result) && + isset($result['result']) && + isset($result['result']['deliverystatus']) && + $result['result']['deliverystatus'] >= 3) + $cacheTime = 0; + else + $cacheTime = 1800; + CacheService::set($cacheName,$result,$cacheTime); + } + $this->assign([ + 'order'=>$order, + 'express'=>$result + ]); + return $this->fetch(); + } + /** + * 修改配送信息 + * @param $id + * @return mixed|\think\response\Json|void + */ + public function distribution($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + $this->assign([ + 'title'=>'配送信息','rules'=>$this->readDistribution($id)->getContent(), + 'action'=>Url::build('updateDistribution',array('id'=>$id)) + ]); + return $this->fetch('public/common_form'); + } + public function readDistribution($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['delivery_type'] == 'send'){ + Form::text('delivery_name','送货人姓名',$product->getData('delivery_name')); + Form::text('delivery_id','送货人电话',$product->getData('delivery_id'))->number(); + }else if($product['delivery_type'] == 'express'){ + Form::select('delivery_name','快递公司',function(){ + $list = Db::name('express')->where('is_show',1)->column('id,name'); + $menus = []; + foreach ($list as $k=>$v){ + $menus[] = ['value'=>$v,'label'=>$v]; + } + return $menus; + },$product->getData('delivery_name'))->filterable(); + Form::text('delivery_id','快递单号',$product->getData('delivery_id')); + } + return Form::builder(); + } + public function updateDistribution(Request $request, $id){ + $data = Util::postMore([ + 'delivery_name', + 'delivery_id', + ],$request); + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['delivery_type'] == 'send'){ + if(!$data['delivery_name']) return Json::fail('请输入送货人姓名'); + if(!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码'); + else if(!preg_match("/^1[3456789]{1}\d{9}$/",$data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码'); + }else if($product['delivery_type'] == 'express'){ + if(!$data['delivery_name']) return Json::fail('请选择快递公司'); + if(!$data['delivery_id']) return Json::fail('请输入快递单号'); + } + StoreOrderModel::edit($data,$id); + HookService::afterListen('store_product_order_distribution',$data,$id,false,OrderBehavior::class); + StoreOrderStatus::setStatus($id,'distribution','修改发货信息为'.$data['delivery_name'].'号'.$data['delivery_id']); + return Json::successful('修改成功!'); + } + /** + * 修改退款状态 + * @param $id + * @return mixed|\think\response\Json|void + */ + public function refund_n($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + $this->assign([ + 'title'=>'退款','rules'=>$this->readRefundN($id)->getContent(), + 'action'=>Url::build('updateRefundN',array('id'=>$id)) + ]); + return $this->fetch('public/common_form'); + } + public function readRefundN($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + Form::text('order_id','退款单号',$product->getData('order_id'))->readonly(); + Form::textarea('refund_reason','退款原因'); + return Form::builder(); + } + public function updateRefundN(Request $request, $id){ + $data = Util::postMore([ + 'refund_reason', + ],$request); + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if(!$data['refund_reason']) return Json::fail('请输入退款原因'); + $data['refund_status'] = 0; + StoreOrderModel::edit($data,$id); + HookService::afterListen('store_product_order_refund_n',$data['refund_reason'],$id,false,OrderBehavior::class); + StoreOrderStatus::setStatus($id,'refund_n','不退款原因:'.$data['refund_reason']); + return Json::successful('修改成功!'); + } + /** + * 立即支付 + * @param $id + */ + public function offline($id){ + $res = StoreOrderModel::updateOffline($id); + if($res){ + try{ + HookService::listen('store_product_order_offline',$id,false,OrderBehavior::class); + }catch (Exception $e){ + return Json::fail($e->getMessage()); + } + StoreOrderStatus::setStatus($id,'offline','线下付款'); + return Json::successful('修改成功!'); + }else{ + return Json::fail('修改失败!'); + } + } + /** + * 修改积分和金额 + * @param $id + * @return mixed|\think\response\Json|void + */ + public function integral_back($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($product['paid'] == 1){ + $this->assign([ + 'title'=>'退积分','rules'=>$this->readIntegralBack($id)->getContent(), + 'action'=>Url::build('updateIntegralBack',array('id'=>$id)) + ]); + }else{ + return Json::fail('参数错误!'); + } + return $this->fetch('public/common_form'); + } + public function readIntegralBack($id){ + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + Form::text('order_id','退积分单号',$product->getData('order_id'))->readonly(); + Form::number('back_integral','退积分')->min(0); + return Form::builder(); + } + public function updateIntegralBack(Request $request, $id){ + $data = Util::postMore([ + 'back_integral', + ],$request); + if(!$id) return $this->failed('数据不存在'); + $product = StoreOrderModel::get($id); + if(!$product) return Json::fail('数据不存在!'); + if($data['back_integral'] <= 0) return Json::fail('请输入积分'); + if($product['use_integral'] == $product['back_integral']) return Json::fail('已退完积分!不能再积分了'); + $back_integral = $data['back_integral']; + $data['back_integral'] = bcadd($data['back_integral'],$product['back_integral'],2); + $bj = bccomp((float)$product['use_integral'],(float)$data['back_integral'],2); + if($bj < 0) return Json::fail('退积分大于支付积分,请修改退积分'); + ModelBasic::beginTrans(); + $integral = User::where('uid',product['uid'])->value('integral'); + $res1 = User::bcInc($product['uid'],'integral',$back_integral,'uid'); + $res2 = UserBill::income('商品退积分',$product['uid'],'integral','pay_product_integral_back',$back_integral,$product['id'],bcadd($integral,$back_integral,2),'订单退积分'.floatval($back_integral).'积分到用户积分'); + try{ + HookService::listen('store_order_integral_back',$product,$back_integral,false,OrderBehavior::class); + }catch (\Exception $e){ + ModelBasic::rollbackTrans(); + return Json::fail($e->getMessage()); + } + $res = $res1 && $res2; + ModelBasic::checkTrans($res); + if(!$res) return Json::fail('退积分失败!'); + StoreOrderModel::edit($data,$id); + StoreOrderStatus::setStatus($id,'integral_back','商品退积分:'.$data['back_integral']); + return Json::successful('退积分成功!'); + } + public function remark(Request $request){ + $data = Util::postMore(['id','remark'],$request); + if(!$data['id']) return Json::fail('参数错误!'); + if($data['remark'] == '') return Json::fail('请输入要备注的内容!'); + $id = $data['id']; + unset($data['id']); + StoreOrderModel::edit($data,$id); + return Json::successful('备注成功!'); + } + public function order_status($oid){ + if(!$oid) return $this->failed('数据不存在'); + $this->assign(StoreOrderStatus::systemPage($oid)); + return $this->fetch(); + } +} diff --git a/application/admin/view/agent/agent_manage/index.php b/application/admin/view/agent/agent_manage/index.php index 2cc21454..77c405bf 100644 --- a/application/admin/view/agent/agent_manage/index.php +++ b/application/admin/view/agent/agent_manage/index.php @@ -8,6 +8,7 @@ + {/block} {block name="content"}
{volist name="list" id="vo"} {eq name="$vo['config_tab_id']" value="$tab_id"}
{switch name="$vo['type']" } {case value="text" break="1"} {/case} {case value="textarea" break="1"} {/case} {case value="checkbox" break="1"} $v){ $option[$k] = explode('=>',$v); } // dump($parameter); // exit(); } $checkbox_value = $vo['value']; if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); // dump($checkbox_value); // exit(); ?> {volist name="option" id="son" key="k"} {if condition="in_array($son[0],$checkbox_value)"} {else/} {/if} {/volist} {/case} {case value="radio" break="1"} $v){ $option[$k] = explode('=>',$v); } } ?> {volist name="option" id="son"} {if condition="$son[0] eq $vo['value']"}
{else /}
{/if} {/volist} {/case} {case value="upload" break="1"} {if condition="$vo['upload_type'] EQ 3"}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
×
{/volist} {/if}
{elseif condition="$vo['upload_type'] EQ 2"/}
{volist name="$vo['value']" id="img"}
image
×
{/volist}
{else/}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
image
×
{/volist}
{/if}
{/if} {/case} {/switch}
{$vo.desc}
{/eq} {/volist}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} +{block name="head"} + + + + + +{/block} +{block name="content"} +
+
+
+ +
+ +
+
+
+ + {volist name="list" id="vo"} + {eq name="$vo['config_tab_id']" value="$tab_id"} +
+ +
+
+
+ {switch name="$vo['type']" } + {case value="text" break="1"} + + {/case} + {case value="textarea" break="1"} + + {/case} + {case value="checkbox" break="1"} + $v){ + $option[$k] = explode('=>',$v); + } +// dump($parameter); + // exit(); + } + $checkbox_value = $vo['value']; + if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); + // dump($checkbox_value); + // exit(); + ?> + {volist name="option" id="son" key="k"} + {if condition="in_array($son[0],$checkbox_value)"} + + {else/} + + {/if} + {/volist} + {/case} + {case value="radio" break="1"} + $v){ + $option[$k] = explode('=>',$v); + } + } + ?> + {volist name="option" id="son"} + {if condition="$son[0] eq $vo['value']"} +
+ +
+ {else /} +
+ +
+ {/if} + {/volist} + {/case} + {case value="upload" break="1"} + + {if condition="$vo['upload_type'] EQ 3"} + + +
+ + {if condition="$num_img LT 1"} +
+
+
+
+ {else/} + {volist name="$vo['value']" id="img"} +
+ +
+ {/volist} + {/if} +
+
+ {elseif condition="$vo['upload_type'] EQ 2"/} +
+ + + +
+ {volist name="$vo['value']" id="img"} +
+
+ +
+ image +
+
+ +
+
×
+ +
+
+ {/volist} +
+
+
+ {else/} +
+ +
+
+ {if condition="$num_img LT 1"} +
+
+
+
+ {else/} + {volist name="$vo['value']" id="img"} +
+
+
+
+ image +
+
×
+ +
+
+
+ {/volist} +
+ {/if} +
+ {/if} + {/case} + {/switch} +
+
+ {$vo.desc} +
+
+
+
+ + {/eq} + {/volist} +
+
+ +
+
+
+
+
+
+
+
+
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/application/admin/view/setting/system_config/index_alone.php b/application/admin/view/setting/system_config/index_alone.php index b098d2a1..b1626f5d 100644 --- a/application/admin/view/setting/system_config/index_alone.php +++ b/application/admin/view/setting/system_config/index_alone.php @@ -1 +1,394 @@ -{extend name="public/container"} {block name="head"} {/block} {block name="content"}
配置
{volist name="list" id="vo"} {eq name="$vo['config_tab_id']" value="$tab_id"}
{switch name="$vo['type']" } {case value="text" break="1"} {/case} {case value="textarea" break="1"} {/case} {case value="checkbox" break="1"} $v){ $option[$k] = explode('=>',$v); } // dump($option); // exit(); } $checkbox_value = $vo['value']; if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); // dump($checkbox_value); // exit(); ?> {volist name="option" id="son" key="k"} {if condition="in_array($son[0],$checkbox_value)"} {else/} {/if} {/volist} {/case} {case value="radio" break="1"} $v){ $option[$k] = explode('=>',$v); } } ?> {volist name="option" id="son"} {if condition="$son[0] eq $vo['value']"}
{else /}
{/if} {/volist} {/case} {case value="upload" break="1"} {if condition="$vo['upload_type'] EQ 3"}
点击上传 {if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
删除
{/volist} {/if}
{elseif condition="$vo['upload_type'] EQ 2"/}
点击上传
{volist name="$vo['value']" id="img"}
image
删除
{/volist}
{else/}
{if condition="$num_img LT 1"}
{else/} {volist name="$vo['value']" id="img"}
image
删除
{/volist}
{/if}
{/if} {/case} {/switch}
{$vo.desc}
{/eq} {/volist}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} +{block name="head"} + + + + + +{/block} +{block name="content"} +
+
+
+
配置
+
+
+
+
+ + {volist name="list" id="vo"} + {eq name="$vo['config_tab_id']" value="$tab_id"} +
+ +
+
+
+ {switch name="$vo['type']" } + {case value="text" break="1"} + + {/case} + {case value="textarea" break="1"} + + {/case} + {case value="checkbox" break="1"} + $v){ + $option[$k] = explode('=>',$v); + } +// dump($option); +// exit(); + } + $checkbox_value = $vo['value']; + if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value); +// dump($checkbox_value); +// exit(); + ?> + {volist name="option" id="son" key="k"} + {if condition="in_array($son[0],$checkbox_value)"} + + {else/} + + {/if} + {/volist} + {/case} + {case value="radio" break="1"} + $v){ + $option[$k] = explode('=>',$v); + } + } + ?> + {volist name="option" id="son"} + {if condition="$son[0] eq $vo['value']"} +
+ +
+ {else /} +
+ +
+ {/if} + {/volist} + {/case} + {case value="upload" break="1"} + + {if condition="$vo['upload_type'] EQ 3"} +
+ + 点击上传 + {if condition="$num_img LT 1"} +
+
+
+
+ {else/} + {volist name="$vo['value']" id="img"} +
+
+ + +
+ +
+
+ +
+
+
删除
+ +
+
+ {/volist} + {/if} +
+
+ {elseif condition="$vo['upload_type'] EQ 2"/} +
+ + 点击上传 +
+ {volist name="$vo['value']" id="img"} +
+
+ + +
+ image +
+
+ +
+
+
删除
+ +
+
+ {/volist} +
+
+
+ {else/} +
+ +
+
+ {if condition="$num_img LT 1"} +
+
+
+
+ {else/} + {volist name="$vo['value']" id="img"} +
+
+
+ + +
+ image +
+
+ +
+
+
删除
+ +
+
+
+ {/volist} +
+ {/if} +
+ {/if} + {/case} + {/switch} +
+
+ {$vo.desc} +
+
+
+
+
+ {/eq} + {/volist} +
+
+ +
+
+
+
+ +
+ +
+
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/application/admin/view/setting/system_config_tab/create.php b/application/admin/view/setting/system_config_tab/create.php index 4ac4781e..20c41a24 100644 --- a/application/admin/view/setting/system_config_tab/create.php +++ b/application/admin/view/setting/system_config_tab/create.php @@ -1 +1,77 @@ - {include file="public/head"} {$title}
\ No newline at end of file + + + + + + + + {include file="public/head"} + + {$title} + + + + + +
+ + + + + + + +
+ + + + + diff --git a/application/admin/view/setting/system_config_tab/create_base.php b/application/admin/view/setting/system_config_tab/create_base.php index adace21f..654196c6 100644 --- a/application/admin/view/setting/system_config_tab/create_base.php +++ b/application/admin/view/setting/system_config_tab/create_base.php @@ -1 +1,62 @@ - {include file="public/head"} {$title}
\ No newline at end of file + + + + + + + + {include file="public/head"} + + {$title} + + + + + +
+ + + + + + +
+ + + + + diff --git a/application/admin/view/setting/system_config_tab/edit.php b/application/admin/view/setting/system_config_tab/edit.php index 7e047874..044f93a2 100644 --- a/application/admin/view/setting/system_config_tab/edit.php +++ b/application/admin/view/setting/system_config_tab/edit.php @@ -1 +1,78 @@ - {include file="public/head"} {$title}
\ No newline at end of file + + + + + + + {include file="public/head"} + + {$title} + + + + + +
+ + + + + + + +
+ + + + + diff --git a/application/admin/view/setting/system_config_tab/edit_cinfig.php b/application/admin/view/setting/system_config_tab/edit_cinfig.php index de4c0cbb..f2d44264 100644 --- a/application/admin/view/setting/system_config_tab/edit_cinfig.php +++ b/application/admin/view/setting/system_config_tab/edit_cinfig.php @@ -1 +1,174 @@ - {include file="public/head"} {$title}
北京市 上海市 深圳市 - 提交 重置 */ ?>
\ No newline at end of file + + + + + + + {include file="public/head"} + + {$title} + + + + + +
+ + + + + + + + + + + + + + + + + + + + 北京市 + + 上海市 + + 深圳市 + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 提交 + + 重置 + + + + + + + + */ ?> + + + + + +
+ + + + + diff --git a/application/admin/view/setting/system_config_tab/index.php b/application/admin/view/setting/system_config_tab/index.php index 8a5829f7..48b9ccb9 100644 --- a/application/admin/view/setting/system_config_tab/index.php +++ b/application/admin/view/setting/system_config_tab/index.php @@ -1 +1,190 @@ -{extend name="public/container"} {block name="content"}
{volist name="list" id="vo"} {/volist}
编号 分类昵称 分类字段 是否显示 操作
{$vo.id} {$vo.title} {$vo.eng_title} {if condition="$vo.status eq 1"} {elseif condition="$vo.status eq 2"/} {/if} {if condition="$vo['id'] gt 2"} {/if}
{include file="public/inner_page"}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} +{block name="content"} +
+
+
+
+ + + + +
+ +
+ +
+
+ +
+ +
+ +
+ + + +
+ + + + + +
+ +
+ +
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + {volist name="list" id="vo"} + + + + + + + + + + + + + + + + {/volist} + + + +
编号分类昵称分类字段是否显示操作
+ + {$vo.id} + + + + {$vo.title} + + + + {$vo.eng_title} + + + + {if condition="$vo.status eq 1"} + + {elseif condition="$vo.status eq 2"/} + + {/if} + + + + + + {if condition="$vo['id'] gt 2"} + + {/if} + +
+ +
+ + {include file="public/inner_page"} + +
+ +
+ +
+ +
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/application/admin/view/setting/system_config_tab/sonconfigtab.php b/application/admin/view/setting/system_config_tab/sonconfigtab.php index 35187b21..54ecb725 100644 --- a/application/admin/view/setting/system_config_tab/sonconfigtab.php +++ b/application/admin/view/setting/system_config_tab/sonconfigtab.php @@ -1 +1,220 @@ -{extend name="public/container"} {block name="content"}
{volist name="list" id="vo"} {/volist}
编号 配置名称 字段变量 字段类型 是否显示 操作
{$vo.id} {$vo.info} {$vo.menu_name} {$vo.type}
image
image
{if condition="$vo.status eq 1"} {elseif condition="$vo.status eq 2"/} {/if}
{/block} {block name="script"} {/block} \ No newline at end of file +{extend name="public/container"} +{block name="content"} +
+ +
+ +
+ +
+ + +
+
+
+ + + + + + + + + + + + + + {volist name="list" id="vo"} + + + + + + + + + + + + + + {/volist} + + + + +
编号配置名称字段变量字段类型是否显示操作
+ {$vo.id} + + {$vo.info} + + {$vo.menu_name} + + {$vo.type} + + +
+ +
+
+ +
+ +
+
+ +
+ image +
+
+ +
+
+
+ + +
+
+ +
+ image +
+
+ +
+
+
+ +
+
+ + +
+ + {if condition="$vo.status eq 1"} + + {elseif condition="$vo.status eq 2"/} + + {/if} + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/application/routine/model/store/StoreBargain.php b/application/routine/model/store/StoreBargain.php index 171befab..95d24a1e 100644 --- a/application/routine/model/store/StoreBargain.php +++ b/application/routine/model/store/StoreBargain.php @@ -156,4 +156,15 @@ class StoreBargain extends ModelBasic if(!$id) return false; return self::where('id',$id)->inc('look',1)->update(); } + + /** + * TODO 判断是否可以出售 + * @param $id + * @param int $cartNum + * @return int|string + * @throws \think\Exception + */ + public static function isValidCartBargain($id,$cartNum = 1){ + return self::validWhere()->where('id',$id)->where('stock','>',$cartNum)->count(); + } } \ No newline at end of file diff --git a/application/routine/model/store/StoreBargainUser.php b/application/routine/model/store/StoreBargainUser.php index a509ab56..743077f2 100644 --- a/application/routine/model/store/StoreBargainUser.php +++ b/application/routine/model/store/StoreBargainUser.php @@ -115,7 +115,7 @@ class StoreBargainUser extends ModelBasic */ public static function getBargainUserDiffPrice($bargainId = 0,$bargainUserId = 0){ $price = self::where('bargain_id',$bargainId)->where('uid',$bargainUserId)->field('bargain_price,bargain_price_min')->find()->toArray(); - return (float)bcsub($price['bargain_price'],$price['bargain_price_min'],0); + return (float)bcsub($price['bargain_price'],$price['bargain_price_min'],2); } /** diff --git a/application/routine/model/store/StoreCombination.php b/application/routine/model/store/StoreCombination.php index 2ba1f316..a0814214 100644 --- a/application/routine/model/store/StoreCombination.php +++ b/application/routine/model/store/StoreCombination.php @@ -157,4 +157,15 @@ class StoreCombination extends ModelBasic return $model->count(); } + /** + * TODO 判断是否可以出售 + * @param $id + * @param int $cartNum + * @return int|string + * @throws \think\Exception + */ + public static function isValidCartCombination($id,$cartNum = 1){ + return self::where('id',$id)->where('is_del',0)->where('is_show',1)->where('stock','>',$cartNum)->count(); + } + } \ No newline at end of file