diff --git a/application/admin/logic/OrderLogic.php b/application/admin/logic/OrderLogic.php index 00719d01..435a73f1 100644 --- a/application/admin/logic/OrderLogic.php +++ b/application/admin/logic/OrderLogic.php @@ -28,13 +28,13 @@ class OrderLogic /** * Notes: 列表查询条件 * @param $get - * @author 段誉(2021/2/1 10:12) * @return array + * @author 段誉(2021/2/1 10:12) */ public static function getListsCondition($get) { $where = []; - + //订单状态 if ($get['type'] != '') { $where[] = ['pay_status', '=', $get['type']]; @@ -55,12 +55,12 @@ class OrderLogic if (isset($get['goods_name']) && $get['goods_name'] != '') { $where[] = ['goods_name', 'like', '%' . $get['goods_name'] . '%']; } - - //商品名称 + + //商品名称 if (isset($get['goods_id']) && $get['goods_id'] != '') { $where[] = ['goods_id', '=', $get['goods_id']]; } - //付款方式 + //付款方式 if (isset($get['order_ysck']) && $get['order_ysck'] != '') { $where[] = ['order_ysck', '=', $get['order_ysck']]; } @@ -68,8 +68,8 @@ class OrderLogic if (isset($get['channel_id']) && $get['channel_id'] != '') { $where[] = ['channel_id', '=', $get['channel_id']]; } - - + + //付款方式 if (isset($get['pay_way']) && $get['pay_way'] != '') { $where[] = ['pay_way', '=', $get['pay_way']]; @@ -80,7 +80,6 @@ class OrderLogic } - //配送方式 if (isset($get['delivery_type']) && $get['delivery_type'] != '') { $where[] = ['delivery_type', '=', $get['delivery_type']]; @@ -110,59 +109,58 @@ class OrderLogic /** * Notes: 列表 * @param $get - * @author 段誉(2021/2/1 10:12) * @return array + * @author 段誉(2021/2/1 10:12) */ public static function lists($get) { $order = new Order(); $where = self::getListsCondition($get); $field = 'o.*,order_status as order_status_text,pay_way as pay_way_text'; - $brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型 - $admin=Db::name('admin')->column('name','id'); + $brand = Db::name('goods_brand')->where(['del' => 0])->column('name', 'id'); //订单类型 + $admin = Db::name('admin')->column('name', 'id'); $count = $order ->where($where) ->count(); $lists = $order ->where($where) - ->page($get['page'],$get['limit']) + ->page($get['page'], $get['limit']) ->order('id desc') ->select(); - $channel = Db::name('orderchannel')->column('name','id'); - foreach ($lists as &$item){ - if(isset($channel[$item['channel_id']])){ + $channel = Db::name('orderchannel')->column('name', 'id'); + foreach ($lists as &$item) { + if (isset($channel[$item['channel_id']])) { $item['channel'] = $channel[$item['channel_id']]; } - if(isset($brand[$item['type_id']])){ + if (isset($brand[$item['type_id']])) { $item['brand'] = $brand[$item['type_id']]; } - if(isset($admin[$item['admin_id']])){ + if (isset($admin[$item['admin_id']])) { $item['admin_id'] = $admin[$item['admin_id']]; } - - - - //获取订单的商品 - $goods=GoodsLogic::goodsinfo($item['goods_id']); - if($goods){ - $item['goods_name']=$goods['name']; - $item['goods_image']=UrlServer::getFileUrl($goods['image']); - $item['code']=$goods['code']; - }else{ - $item['goods_name']=''; - $item['goods_image']=''; - $item['code']=''; - } - $gord_id=Db::name('collection')->where('id',$item['gord_id'])->find(); - if($gord_id){ - $item['gord_name']= $gord_id['cqname']; - }else{ - $item['gord_name']='-'; + + //获取订单的商品 + $goods = GoodsLogic::goodsinfo($item['goods_id']); + if ($goods) { + $item['goods_name'] = $goods['name']; + $item['goods_image'] = UrlServer::getFileUrl($goods['image']); + $item['code'] = $goods['code']; + } else { + $item['goods_name'] = ''; + $item['goods_image'] = ''; + $item['code'] = ''; + } + + $gord_id = Db::name('collection')->where('id', $item['gord_id'])->find(); + if ($gord_id) { + $item['gord_name'] = $gord_id['cqname']; + } else { + $item['gord_name'] = '-'; } } - + return ['count' => $count, 'lists' => $lists]; } @@ -199,7 +197,7 @@ class OrderLogic break; } } - + //商品名称 if (isset($get['goods_name']) && $get['goods_name'] != '') { $where[] = ['g.name', 'like', '%' . $get['goods_name'] . '%']; @@ -236,178 +234,178 @@ class OrderLogic $field = 'o.*,o.order_type as order_type_text, o.order_source as order_source_text,o.pay_way as pay_way_text,address as delivery_address,o.pay_status as pay_status_text,o.order_status as order_status_text,u.sn as user_sn,u.nickname as user_nickname,u.level as user_level'; $lists = Order::alias('o') - ->join('user u','u.id=o.user_id') - ->join('order_goods og', 'og.order_id=o.id') - ->join('goods g', 'g.id=og.goods_id') - ->with('order_goods') - ->field($field) - ->where($where) - ->order('o.id', 'desc') - ->group('og.order_id') - ->select() - ->toArray(); + ->join('user u', 'u.id=o.user_id') + ->join('order_goods og', 'og.order_id=o.id') + ->join('goods g', 'g.id=og.goods_id') + ->with('order_goods') + ->field($field) + ->where($where) + ->order('o.id', 'desc') + ->group('og.order_id') + ->select() + ->toArray(); - $userLevel = UserLevel::where('del', 0)->column(['id','name'], 'id'); + $userLevel = UserLevel::where('del', 0)->column(['id', 'name'], 'id'); $exportTitle = ['订单编号', '订单类型', '下单时间', '支付时间', '订单来源', '会员编号', '会员昵称', '会员等级', '商品信息', '商品数量', '运费金额', '商品总金额', '优惠金额', '应付金额', '支付方式', '收货人', '手机号码', '收货地址', '配送方式', '支付状态', '订单状态']; $exportExt = 'xls'; $exportData = []; - foreach ($lists as $item){ - $orderSn = 'SN'.$item['order_sn']; // 转字符串 - $level = isset($userLevel[$item['user_level']]) ? $userLevel[$item['user_level']] : '无等级'; + foreach ($lists as $item) { + $orderSn = 'SN' . $item['order_sn']; // 转字符串 + $level = isset($userLevel[$item['user_level']]) ? $userLevel[$item['user_level']] : '无等级'; $deliveryType = Order::getDeliveryType($item['delivery_type']); $goodsStr = ''; - foreach($item['order_goods'] as $subItem) { + foreach ($item['order_goods'] as $subItem) { $goodsInfo = json_decode($subItem['goods_info'], true); - $goodsStr.= '【'.$goodsInfo['goods_name'].' 规格:'.$goodsInfo['spec_value_str']. ' 数量:'.$subItem['goods_num']. '】'; + $goodsStr .= '【' . $goodsInfo['goods_name'] . ' 规格:' . $goodsInfo['spec_value_str'] . ' 数量:' . $subItem['goods_num'] . '】'; } - $exportData[] = [$orderSn, $item['order_type_text'], $item['create_time'], $item['pay_time'], $item['order_source_text'], $item['user_sn'], $item['user_nickname'], $level, $goodsStr,$item['total_num'], $item['shipping_price'], $item['goods_price'], $item['discount_amount'], $item['order_amount'], $item['pay_way_text'], $item['consignee'], $item['mobile'], $item['delivery_address'],$deliveryType, $item['pay_status_text'], $item['order_status_text']]; + $exportData[] = [$orderSn, $item['order_type_text'], $item['create_time'], $item['pay_time'], $item['order_source_text'], $item['user_sn'], $item['user_nickname'], $level, $goodsStr, $item['total_num'], $item['shipping_price'], $item['goods_price'], $item['discount_amount'], $item['order_amount'], $item['pay_way_text'], $item['consignee'], $item['mobile'], $item['delivery_address'], $deliveryType, $item['pay_status_text'], $item['order_status_text']]; } - return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'订单列表'.date('Y-m-d H:i:s')]; + return ['exportTitle' => $exportTitle, 'exportData' => $exportData, 'exportExt' => $exportExt, 'exportName' => '订单列表' . date('Y-m-d H:i:s')]; } - - public static function exportorder($get){ - $where[] = ['o.del', '=', 0]; - $where = self::getListsCondition($get); - $lists=Db::name('order')->where($where)->select(); //获取订单的内容 - - $exportData = []; - foreach ($lists as $item){ - $orderSn = 'DL'.$item['order_sn']; // 转字符串 - $goods=Db::name('goods')->where('id',$item['goods_id'])->find(); //获取商品的基本信息 - $ervice=Db::name('order_exe') - ->where('order_sn',$item['order_sn']) - ->where('staff_status',3) - ->count(); //查询服务条数 - - if($item['pay_status']==1){ - $item['order_status_text']='已支付'; - }else{ - $item['order_status_text']='未支付'; + + public static function exportorder($get) + { + $where[] = ['o.del', '=', 0]; + $where = self::getListsCondition($get); + $lists = Db::name('order')->where($where)->select(); //获取订单的内容 + + $exportData = []; + foreach ($lists as $item) { + $orderSn = 'DL' . $item['order_sn']; // 转字符串 + $goods = Db::name('goods')->where('id', $item['goods_id'])->find(); //获取商品的基本信息 + $ervice = Db::name('order_exe') + ->where('order_sn', $item['order_sn']) + ->where('staff_status', 3) + ->count(); //查询服务条数 + + if ($item['pay_status'] == 1) { + $item['order_status_text'] = '已支付'; + } else { + $item['order_status_text'] = '未支付'; } - - $admin=Db::name('admin')->where('id',$item['admin_id'])->find(); //查询客服id - if($admin){ - $admin_name=$admin['name']; - }else{ - $admin_name='-'; + + $admin = Db::name('admin')->where('id', $item['admin_id'])->find(); //查询客服id + if ($admin) { + $admin_name = $admin['name']; + } else { + $admin_name = '-'; } - - $channe=Db::name('orderchannel')->where('id',$item['channel_id'])->find(); //查询渠道内容 - - if($channe){ - $channe_name=$channe['name']; - }else{ - $channe_name='-'; + + $channe = Db::name('orderchannel')->where('id', $item['channel_id'])->find(); //查询渠道内容 + + if ($channe) { + $channe_name = $channe['name']; + } else { + $channe_name = '-'; } - $phone=Db::name('user_address')->where('telephone',$item['mobile'])->find(); - if($phone){ - $cnle=Db::name('staffchannel')->where('id',$phone['brand_id'])->find(); - if($cnle){ - $custom= $cnle['name']; - }else{ - $custom='-'; - } + $phone = Db::name('user_address')->where('telephone', $item['mobile'])->find(); + if ($phone) { + $cnle = Db::name('staffchannel')->where('id', $phone['brand_id'])->find(); + if ($cnle) { + $custom = $cnle['name']; + } else { + $custom = '-'; + } } - $dsynumber=$item['number']-$ervice; - - - - - if($item['pay_zd']==0){ - $item['pay_zd']='已收款'; - }else{ - $item['pay_zd']='未收款'; + $dsynumber = $item['number'] - $ervice; + + + if ($item['pay_zd'] == 0) { + $item['pay_zd'] = '已收款'; + } else { + $item['pay_zd'] = '未收款'; } - $exportData[] = [$orderSn,$item['consignee'], $item['mobile'],$item['address'],$admin_name,$goods['name'],$goods['min_price'], - $item['order_amount'],$channe_name,$custom,$item['order_status_text'],$item['pay_zd'],$item['number'],$ervice,$dsynumber,date('Y-m-d H:i:s',$item['create_time']) - ]; - $exportTitle = ['订单序号','客户姓名','客户电话','房屋地址','订单归属','套餐名称','套餐金额','付款金额','订单渠道','客户渠道','是否收款','是否支付','总次数','已使用','待使用','下单时间']; - $exportExt = 'xls'; - } - return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'订单列表'.date('Y-m-d H:i:s')]; + $exportData[] = [$orderSn, $item['consignee'], $item['mobile'], $item['address'], $admin_name, $goods['name'], $goods['min_price'], + $item['order_amount'], $channe_name, $custom, $item['order_status_text'], $item['pay_zd'], $item['number'], $ervice, $dsynumber, date('Y-m-d H:i:s', $item['create_time']) + ]; + $exportTitle = ['订单序号', '客户姓名', '客户电话', '房屋地址', '订单归属', '套餐名称', '套餐金额', '付款金额', '订单渠道', '客户渠道', '是否收款', '是否支付', '总次数', '已使用', '待使用', '下单时间']; + $exportExt = 'xls'; + } + return ['exportTitle' => $exportTitle, 'exportData' => $exportData, 'exportExt' => $exportExt, 'exportName' => '订单列表' . date('Y-m-d H:i:s')]; } /** * Notes: 我的订单导出功能 * @param $get - * @author 段誉(2021/2/1 10:12) * @return array + * @author 段誉(2021/2/1 10:12) */ - public static function userexport($get){ - - $where=[]; - $where = self::getListsCondition($get); - $lists=Db::name('order') - ->where($where) - ->where('admin_id',session('admin_info.id')) - ->select(); //获取订单的内容 + public static function userexport($get) + { - $exportData = []; - foreach ($lists as $item){ - $orderSn = 'DL'.$item['order_sn']; // 转字符串 - $goods=Db::name('goods')->where('id',$item['goods_id'])->find(); //获取商品的基本信息 - $ervice=Db::name('order_exe') - ->where('order_sn',$item['order_sn']) - ->where('staff_status',3) - ->count(); //查询服务条数 - - if($item['pay_status']==1){ - $item['order_status_text']='已支付'; - }else{ - $item['order_status_text']='未支付'; + $where = []; + $where = self::getListsCondition($get); + $lists = Db::name('order') + ->where($where) + ->where('admin_id', session('admin_info.id')) + ->select(); //获取订单的内容 + + $exportData = []; + foreach ($lists as $item) { + $orderSn = 'DL' . $item['order_sn']; // 转字符串 + $goods = Db::name('goods')->where('id', $item['goods_id'])->find(); //获取商品的基本信息 + $ervice = Db::name('order_exe') + ->where('order_sn', $item['order_sn']) + ->where('staff_status', 3) + ->count(); //查询服务条数 + + if ($item['pay_status'] == 1) { + $item['order_status_text'] = '已支付'; + } else { + $item['order_status_text'] = '未支付'; } - - $admin=Db::name('admin')->where('id',$item['admin_id'])->find(); //查询客服id - if($admin){ - $admin_name=$admin['name']; - }else{ - $admin_name='-'; + + $admin = Db::name('admin')->where('id', $item['admin_id'])->find(); //查询客服id + if ($admin) { + $admin_name = $admin['name']; + } else { + $admin_name = '-'; } - - $channe=Db::name('orderchannel')->where('id',$item['channel_id'])->find(); //查询渠道内容 - - if($channe){ - $channe_name=$channe['name']; - }else{ - $channe_name='-'; + + $channe = Db::name('orderchannel')->where('id', $item['channel_id'])->find(); //查询渠道内容 + + if ($channe) { + $channe_name = $channe['name']; + } else { + $channe_name = '-'; } - $phone=Db::name('user_address')->where('telephone',$item['mobile'])->find(); - if($phone){ - $cnle=Db::name('staffchannel')->where('id',$phone['brand_id'])->find(); - if($cnle){ - $custom= $cnle['name']; - }else{ - $custom='-'; - } + $phone = Db::name('user_address')->where('telephone', $item['mobile'])->find(); + if ($phone) { + $cnle = Db::name('staffchannel')->where('id', $phone['brand_id'])->find(); + if ($cnle) { + $custom = $cnle['name']; + } else { + $custom = '-'; + } } - - if($item['pay_zd']==0){ - $item['pay_zd']='已收款'; - }else{ - $item['pay_zd']='未收款'; + + if ($item['pay_zd'] == 0) { + $item['pay_zd'] = '已收款'; + } else { + $item['pay_zd'] = '未收款'; } - $exportData[] = [$orderSn,$item['consignee'], $item['mobile'],$item['address'],$admin_name,$goods['name'],$goods['min_price'], - $item['order_amount'],$channe_name,$custom,$item['order_status_text'],$item['pay_zd'],date('Y-m-d H:i:s',$item['create_time']) - ]; - $exportTitle = ['订单序号','客户姓名','客户电话','房屋地址','订单归属','套餐名称','套餐金额','付款金额','订单渠道','客户渠道','是否收款','是否支付','下单时间']; - $exportExt = 'xls'; - } - - - return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'订单列表'.date('Y-m-d H:i:s')]; + $exportData[] = [$orderSn, $item['consignee'], $item['mobile'], $item['address'], $admin_name, $goods['name'], $goods['min_price'], + $item['order_amount'], $channe_name, $custom, $item['order_status_text'], $item['pay_zd'], date('Y-m-d H:i:s', $item['create_time']) + ]; + $exportTitle = ['订单序号', '客户姓名', '客户电话', '房屋地址', '订单归属', '套餐名称', '套餐金额', '付款金额', '订单渠道', '客户渠道', '是否收款', '是否支付', '下单时间']; + $exportExt = 'xls'; + } + + + return ['exportTitle' => $exportTitle, 'exportData' => $exportData, 'exportExt' => $exportExt, 'exportName' => '订单列表' . date('Y-m-d H:i:s')]; } // 子订单的导出 public static function exportFilestaff($get) { - - $where=[]; - + $where = []; + + //订单类型 if (isset($get['satff']) && $get['satff'] != '') { $where[] = ['staff_id', '=', $get['satff']]; @@ -425,142 +423,143 @@ class OrderLogic $where[] = ['autotime', '<=', strtotime($get['end_time'])]; } - $lists=Db::name('order_exe') - ->where($where) - ->select(); + $lists = Db::name('order_exe') + ->where($where) + ->select(); $exportData = []; - foreach ($lists as $item){ - $order=Db::name('order')->where('order_sn',$item['order_sn'])->find(); //主订单的基本信息 - $goods=Db::name('goods')->where('id',$order['goods_id'])->find(); //获取套餐的名称 - if($goods){ - $goods['name']=$goods['name']; - }else{ - $goods['name']='-'; - } - $coumst=Db::name('orderchannel')->where('id',$order['channel_id'])->find(); //获取订单的渠道 - $staff=Db::name('staff')->where('id',$item['staff_id'])->find(); //获取员工的基本信息 - - $admin=Db::name('admin')->where('id',$order['admin_id'])->find(); //获取客服管家 - - if($admin){ - $admin['name']=$admin['name']; - }else{ - $admin['name']='-'; - } - if($coumst){ - $coumst['name']= $coumst['name']; - }else{ - $coumst['name']= '-'; - } - if($staff){ - $staff['name']= $staff['name']; - }else{ - $staff['name']= '-'; - } - $xdtime=date('Y-m-d',$order['create_time']); //下单日期 - $autotime=date('Y-m-d',$item['autotime']); //服务日期 - - if($order['number']>12){ - $item['yeaey']='是'; - }else{ - $item['yeaey']='否'; - } - if($item['addtime']==1){ - $item['addtime']='上午'; - }else{ - $item['addtime']='下午'; - } - $tiem['sfsk']=$order['integral_amount']; - $adder=Db::name('dev_region')->where('id',$order['district'])->find(); //获取到地区信息 - $adderss=Db::name('user_address')->where('telephone',$order['mobile'])->find(); //客户的房屋地址 - - if($adderss){ - $couadderss=Db::name('admin')->where('id',$adderss['admin_id'])->find(); - if($couadderss){ - $couadderss['name_adder']=$couadderss['name']; - } - } - - if($adder){ - $adder=$adder['name']; - }else{ - $adder['name']='-'; - } - - $timeadd=Db::name('order_timeadd') - ->where('orderid',$item['id']) - ->where('status',2) - ->find(); - if($timeadd){ - $item['addtimes']=$timeadd['minute']/60; - }else{ - $item['addtimes']=0; - } - - if($item['staff_status']==0){ - $item['statusdd']="等待接单"; - } - if($item['staff_status']==1){ - $item['statusdd']="等待上门"; - } - if($item['staff_status']==2){ - $item['statusdd']="等待服务"; - } - if($item['staff_status']==3){ - $item['statusdd']="服务完成"; - } + foreach ($lists as $item) { + $order = Db::name('order')->where('order_sn', $item['order_sn'])->find(); //主订单的基本信息 + $goods = Db::name('goods')->where('id', $order['goods_id'])->find(); //获取套餐的名称 + if ($goods) { + $goods['name'] = $goods['name']; + } else { + $goods['name'] = '-'; + } + $coumst = Db::name('orderchannel')->where('id', $order['channel_id'])->find(); //获取订单的渠道 + $staff = Db::name('staff')->where('id', $item['staff_id'])->find(); //获取员工的基本信息 + + $admin = Db::name('admin')->where('id', $order['admin_id'])->find(); //获取客服管家 + + if ($admin) { + $admin['name'] = $admin['name']; + } else { + $admin['name'] = '-'; + } + if ($coumst) { + $coumst['name'] = $coumst['name']; + } else { + $coumst['name'] = '-'; + } + if ($staff) { + $staff['name'] = $staff['name']; + } else { + $staff['name'] = '-'; + } + $xdtime = date('Y-m-d', $order['create_time']); //下单日期 + $autotime = date('Y-m-d', $item['autotime']); //服务日期 + + if ($order['number'] > 12) { + $item['yeaey'] = '是'; + } else { + $item['yeaey'] = '否'; + } + if ($item['addtime'] == 1) { + $item['addtime'] = '上午'; + } else { + $item['addtime'] = '下午'; + } + $tiem['sfsk'] = $order['integral_amount']; + $adder = Db::name('dev_region')->where('id', $order['district'])->find(); //获取到地区信息 + $adderss = Db::name('user_address')->where('telephone', $order['mobile'])->find(); //客户的房屋地址 + + if ($adderss) { + $couadderss = Db::name('admin')->where('id', $adderss['admin_id'])->find(); + if ($couadderss) { + $couadderss['name_adder'] = $couadderss['name']; + } + } + + if ($adder) { + $adder = $adder['name']; + } else { + $adder['name'] = '-'; + } + + $timeadd = Db::name('order_timeadd') + ->where('orderid', $item['id']) + ->where('status', 2) + ->find(); + if ($timeadd) { + $item['addtimes'] = $timeadd['minute'] / 60; + } else { + $item['addtimes'] = 0; + } + + if ($item['staff_status'] == 0) { + $item['statusdd'] = "等待接单"; + } + if ($item['staff_status'] == 1) { + $item['statusdd'] = "等待上门"; + } + if ($item['staff_status'] == 2) { + $item['statusdd'] = "等待服务"; + } + if ($item['staff_status'] == 3) { + $item['statusdd'] = "服务完成"; + } $exportData[] = [ - $order['order_sn'], - $order['mobile'],$order['consignee'], - $adder, - $order['address'], - $goods['name'],//套餐名称 - $xdtime ,$autotime, - $item['addtime'], - $item['statusdd'] - ,$order['order_amount'],$tiem['sfsk'], - $item['addtimes'],$item['add'],$item['yeaey'] - ,$order['number'],$order['code'], - $coumst['name'], - $staff['name'],$item['account'], - $admin['name'], - $couadderss['name_adder'], - $item['remark']]; - - $exportTitle = ['订单编号','手机号码','客户名称','区','详细地址','套餐名称','下单日期','服务日期','上午/下午','服务状态','订单总金额','优惠券抵用金额','加时','是否收款','是否年卡',' 总次数','剩余次数','渠道','员工姓名','报销','订单归属','客户归属','订单备注']; - $exportExt = 'xls'; + $order['order_sn'], + $order['mobile'], $order['consignee'], + $adder, + $order['address'], + $goods['name'],//套餐名称 + $xdtime, $autotime, + $item['addtime'], + $item['statusdd'] + , $order['order_amount'], $tiem['sfsk'], + $item['addtimes'], $item['add'], $item['yeaey'] + , $order['number'], $order['code'], + $coumst['name'], + $staff['name'], $item['account'], + $admin['name'], + $couadderss['name_adder'], + $item['remark']]; + + $exportTitle = ['订单编号', '手机号码', '客户名称', '区', '详细地址', '套餐名称', '下单日期', '服务日期', '上午/下午', '服务状态', '订单总金额', '优惠券抵用金额', '加时', '是否收款', '是否年卡', ' 总次数', '剩余次数', '渠道', '员工姓名', '报销', '订单归属', '客户归属', '订单备注']; + $exportExt = 'xls'; } - return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'订单列表'.date('Y-m-d H:i:s')]; + return ['exportTitle' => $exportTitle, 'exportData' => $exportData, 'exportExt' => $exportExt, 'exportName' => '订单列表' . date('Y-m-d H:i:s')]; } /** * Notes: 详情 * @param $id - * @author 段誉(2021/2/1 10:12) * @return Order + * @author 段誉(2021/2/1 10:12) */ public static function getDetail($id) { - - $result = Db::name('order') + + $result = Db::name('order') ->where('id', $id) ->find(); - $goods=Db::name('goods')->where('id', $result['goods_id'])->find(); - $result['goods_image']= UrlServer::getFileUrl($goods['image']); - $result['goods_name']= $goods['name']; - if($result['type']=1){ - $result['type']="固定订单"; - }else{ - $result['type']="非固定订单"; - } - $result['create_time']=date("Y-m-d H:i:s",$result['create_time']); - if($result['pay_status']==1){ - $result['pay_status']="已支付"; - } + $goods = Db::name('goods')->where('id', $result['goods_id'])->find(); + $result['goods_image'] = UrlServer::getFileUrl($goods['image']); + $result['goods_name'] = $goods['name']; + if ($result['type'] = 1) { + $result['type'] = "固定订单"; + } else { + $result['type'] = "非固定订单"; + } + $result['create_time'] = date("Y-m-d H:i:s", $result['create_time']); + if ($result['pay_status'] == 1) { + $result['pay_status'] = "已支付"; + } return $result; } + /** * Notes: 取消订单(返回商品规格表库存) * @param $order_id @@ -570,7 +569,7 @@ class OrderLogic public static function cancel($order_id, $admin_id) { Db::startTrans(); - try{ + try { $order = Order::get(['id' => $order_id], ['orderGoods']); //取消订单 OrderRefundLogic::cancelOrder($order_id, OrderLog::TYPE_SHOP, $admin_id); @@ -584,7 +583,7 @@ class OrderLogic Db::commit(); return true; - } catch(\Exception $e) { + } catch (\Exception $e) { Db::rollback(); //增加退款失败记录 OrderRefundLogic::addErrorRefund($order, $e->getMessage()); @@ -618,11 +617,11 @@ class OrderLogic /** * Notes: 物流公司 - * @author 段誉(2021/2/1 10:15) * @return array|\PDOStatement|string|\think\Collection * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @author 段誉(2021/2/1 10:15) */ public static function express() { @@ -630,19 +629,17 @@ class OrderLogic } - - /** * Notes: 发货操作 * @param $data * @param $admin_id - * @author 段誉(2021/2/1 10:15) * @return bool * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException + * @author 段誉(2021/2/1 10:15) */ public static function deliveryHandle($data, $admin_id) { @@ -678,7 +675,7 @@ class OrderLogic $delivery_data['shipping_status'] = 1; } $delivery_id = Db::name('delivery')->insertGetId($delivery_data); - + //更新订单下商品的发货状态 $order->update_time = time(); $order->shipping_time = time(); @@ -697,19 +694,19 @@ class OrderLogic ); //发货短信通知 - if($order->mobile){ + if ($order->mobile) { $nickname = Db::name('user')->where(['id' => $order['user_id']])->value('nickname'); $send_data = [ 'key' => NoticeSetting::ORDER_DELIVERY_NOTICE, - 'user_id' => $order['user_id'], + 'user_id' => $order['user_id'], 'mobile' => $order->mobile, 'params' => [ 'order_sn' => $order->order_sn, 'nickname' => $nickname, - 'time' => date('Y-m-d H:i:s'), - 'invoice_no' => $data['invoice_no'] ?? '', + 'time' => date('Y-m-d H:i:s'), + 'invoice_no' => $data['invoice_no'] ?? '', 'shipping_name' => $delivery_data['shipping_name'] ?? '无需快递', - 'goods_name' => omit_str($order['order_goods'][0]['goods_name'] ?? '商品', 8) + 'goods_name' => omit_str($order['order_goods'][0]['goods_name'] ?? '商品', 8) ], ]; } @@ -718,7 +715,7 @@ class OrderLogic // 赠送成长值和积分 Hook::listen('give_reward', [ 'order_id' => $order['id'], - 'scene' => 2, //2=发货场景 + 'scene' => 2, //2=发货场景 ]); // 发货模板消息 @@ -727,14 +724,12 @@ class OrderLogic 'order_id' => $order['id'], 'scene' => NoticeSetting::ORDER_DELIVERY_NOTICE, 'shipping_name' => $delivery_data['shipping_name'] ?? '无需快递', - 'invoice_no' => $data['invoice_no'] ?? '', + 'invoice_no' => $data['invoice_no'] ?? '', 'time' => date('Y-m-d H:i:s') ]); } - - /** * Notes: 确认收货 * @param $order_id @@ -752,7 +747,7 @@ class OrderLogic // 赠送成长值和积分 Hook::listen('give_reward', [ 'order_id' => $order_id, - 'scene' => 3, //3=订单完成 + 'scene' => 3, //3=订单完成 ]); //订单日志 @@ -766,15 +761,14 @@ class OrderLogic } - /** * Notes: 物流信息 * @param $order_id - * @author 段誉(2021/2/1 10:16) * @return array|\PDOStatement|string|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @author 段誉(2021/2/1 10:16) */ public static function shippingInfo($order_id) { @@ -790,11 +784,11 @@ class OrderLogic /** * Notes: 物流轨迹 * @param $order_id - * @author 段誉(2021/2/1 10:16) * @return array|bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @author 段誉(2021/2/1 10:16) */ public static function getShipping($order_id) { @@ -814,7 +808,7 @@ class OrderLogic } //快递配置设置为快递鸟时 - if($express === 'kdniao') { + if ($express === 'kdniao') { $expressage = (new Kdniao($key, $app, Env::get('app.app_debug', 'true'))); $shipping_field = 'codebird'; } else { @@ -849,17 +843,17 @@ class OrderLogic * @throws \think\exception\PDOException * @author 张无忌(2021/2/1 18:50) */ - public static function remarks($post, $type="get") + public static function remarks($post, $type = "get") { - if ($type==='get') { + if ($type === 'get') { return Db::name('order')->field('id,order_remarks') - ->where(['id'=>$post['id']]) + ->where(['id' => $post['id']]) ->findOrEmpty(); } else { return Db::name('order') - ->where(['id'=>$post['id']]) - ->update(['order_remarks'=>$post['order_remarks']]); + ->where(['id' => $post['id']]) + ->update(['order_remarks' => $post['order_remarks']]); } } @@ -868,40 +862,42 @@ class OrderLogic * @param $id int 订单id * @return string */ - public static function orderPrint($id){ + public static function orderPrint($id) + { try { //打印机配置 - $printer_config = Db::name('printer_config')->where(['status'=>1])->find(); + $printer_config = Db::name('printer_config')->where(['status' => 1])->find(); //打印机列表 - $printer_list = Db::name('printer')->where(['type'=>$printer_config['id'],'del'=>0])->select(); + $printer_list = Db::name('printer')->where(['type' => $printer_config['id'], 'del' => 0])->select(); - if(empty($printer_config) || empty($printer_list)){ + if (empty($printer_config) || empty($printer_list)) { throw new Exception('请先配置打印机'); } - $yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']); + $yly_print = new YlyPrinter($printer_config['client_id'], $printer_config['client_secret']); $order = self::getPrintOrder($id); $template_config = ConfigServer::get('printer', 'yly_template', []); - $yly_print->ylyPrint($printer_list,$order,$template_config); + $yly_print->ylyPrint($printer_list, $order, $template_config); - }catch (\Exception $e){ + } catch (\Exception $e) { - $msg = json_decode($e->getMessage(),true); - if($msg && isset($msg['error'])){ - return '易联云:'.$msg['error_description']; + $msg = json_decode($e->getMessage(), true); + if ($msg && isset($msg['error'])) { + return '易联云:' . $msg['error_description']; } - if(18 === $e->getCode()){ + if (18 === $e->getCode()) { //todo token过期重新拿 Cache::rm('yly_access_token'); Cache::rm('yly_refresh_token'); }; - return '易联云:'.$e->getMessage(); + return '易联云:' . $e->getMessage(); } } - public static function getPrintOrder($id){ + public static function getPrintOrder($id) + { $order = new Order(); $result = $order ->with(['user', 'order_goods']) @@ -920,66 +916,78 @@ class OrderLogic } //后台增加订单 - public static function add($post){ - $adder=UserLogic::adder($post['user_id']); //获取用户的地址 - $goods=Db::name('goods')->where('id',$post['goods_id'])->find(); //获取商品的ID - $user=Db::name('user')->where('mobile',$adder['telephone'])->find(); - if($user){ - $user['id']= $user['id']; - }else{ - $user['id']=0; + public static function add($post) + { + $adder = UserLogic::adder($post['user_id']); //获取用户的地址 + $goods = Db::name('goods')->where('id', $post['goods_id'])->find(); //获取商品的ID + $user = Db::name('user')->where('mobile', $adder['telephone'])->find(); + if ($user) { + $user['id'] = $user['id']; + } else { + $user['id'] = 0; } - - if($post['gord_id']){ - $post['gord_id']=$post['gord_id']; - }else{ - $post['gord_id']=0; + + if ($post['gord_id']) { + $post['gord_id'] = $post['gord_id']; + } else { + $post['gord_id'] = 0; } - $post['order_sn']=createSn('order', 'order_sn', '', 4); - $data=[ - 'order_sn'=> $post['order_sn'], - 'goods_id'=>$post['goods_id'], - 'user_id'=>$user['id'], - 'consignee'=>$adder['contact'], - 'province'=>$adder['province_id'], - 'city'=>$adder['city_id'], - 'district'=>$adder['district_id'], - 'address'=>$adder['address'], - 'mobile'=>$adder['telephone'], - 'lat'=>$adder['lat'], - 'lng'=>$adder['lng'], - 'goods_price'=>$post['total_amount'], - 'order_amount'=>$post['total_amount'], - 'total_amount'=>$post['total_amount'], - 'pay_zd'=>$post['order_ysck'], - 'pay_status'=>1, - 'code'=>$goods['code'], - 'number'=>$goods['code'], - 'channel_id'=>$post['channel_id'], - 'admin_id' =>session('admin_info.id'), - 'order_ysck'=>$post['order_ysck'], - 'gord_id'=>$post['gord_id'], - 'create_time'=>time(), - 'update_time'=>time(), + $post['order_sn'] = createSn('order', 'order_sn', '', 4); + if ($post['order_ysck'] == 1) { + $pay_status = 0; + $order_status = 0; + } else { + $pay_status = 1; + $order_status = 1; + } + $data = [ + 'order_sn' => $post['order_sn'], + 'goods_id' => $post['goods_id'], + 'user_id' => $user['id'], + 'consignee' => $adder['contact'], + 'province' => $adder['province_id'], + 'city' => $adder['city_id'], + 'district' => $adder['district_id'], + 'address' => $adder['address'], + 'mobile' => $adder['telephone'], + 'lat' => $adder['lat'], + 'lng' => $adder['lng'], + 'goods_price' => $post['total_amount'], +// 'order_amount'=>$post['total_amount'], + 'order_amount' => $goods['max_price'], + 'total_amount' => $post['total_amount'], + 'pay_zd' => $post['order_ysck'], + 'pay_status' => $pay_status, + 'order_status' => $order_status, + 'code' => $goods['code'], + 'number' => $goods['code'], + 'channel_id' => $post['channel_id'], + 'admin_id' => session('admin_info.id'), + 'order_ysck' => $post['order_ysck'], + 'gord_id' => $post['gord_id'], + 'create_time' => time(), + 'update_time' => time(), ]; return Db::name('order')->data($data)->insert(); } //根据订单编号获取到订单信息 - public static function orderinfo($order_sn){ - return Db::name('order')->where('order_sn',$order_sn)->find(); + public static function orderinfo($order_sn) + { + return Db::name('order')->where('order_sn', $order_sn)->find(); } //根据订单ID获取到订单信息 - public static function orderinfoid($id){ - return Db::name('order')->where('id',$id)->find(); + public static function orderinfoid($id) + { + return Db::name('order')->where('id', $id)->find(); } - + public static function userlists($get) { - - $where=[]; + + $where = []; //订单搜素 if (!empty($get['search_key']) && !empty($get['keyword'])) { $keyword = $get['keyword']; @@ -1004,7 +1012,7 @@ class OrderLogic break; } } - + //商品名称 if (isset($get['goods_name']) && $get['goods_name'] != '') { $where[] = ['g.name', 'like', '%' . $get['goods_name'] . '%']; @@ -1037,73 +1045,77 @@ class OrderLogic if (isset($get['end_time']) && $get['end_time'] != '') { $where[] = ['o.create_time', '<=', strtotime($get['end_time'])]; } - + $order = new Order(); $where = self::getListsCondition($get); $field = 'o.*,order_status as order_status_text,pay_way as pay_way_text'; - $brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型 + $brand = Db::name('goods_brand')->where(['del' => 0])->column('name', 'id'); //订单类型 $count = $order ->where($where) - ->where('admin_id',session('admin_info.id')) - ->order('id desc') + ->where('admin_id', session('admin_info.id')) + ->order('id desc') ->count(); $lists = $order ->where($where) - ->where('admin_id',session('admin_info.id')) - ->page($get['page'],$get['limit']) + ->where('admin_id', session('admin_info.id')) + ->page($get['page'], $get['limit']) ->order('id desc') ->select(); - $channel = Db::name('orderchannel')->column('name','id'); - foreach ($lists as &$item){ - if(isset($channel[$item['channel_id']])){ + $channel = Db::name('orderchannel')->column('name', 'id'); + foreach ($lists as &$item) { + if (isset($channel[$item['channel_id']])) { $item['channel'] = $channel[$item['channel_id']]; } - if(isset($brand[$item['type_id']])){ + if (isset($brand[$item['type_id']])) { $item['brand'] = $brand[$item['type_id']]; } - //获取订单的商品 - $goods=Db::name('goods')->where('id',$item['goods_id'])->find(); - if($goods){ - $item['goods_name']=$goods['name']; - $item['goods_image']=UrlServer::getFileUrl($goods['image']); - $item['code']=$goods['code']; - }else{ - $item['goods_name']=''; - $item['goods_image']=''; - $item['code']=''; + //获取订单的商品 + $goods = Db::name('goods')->where('id', $item['goods_id'])->find(); + if ($goods) { + $item['goods_name'] = $goods['name']; + $item['goods_image'] = UrlServer::getFileUrl($goods['image']); + $item['code'] = $goods['code']; + } else { + $item['goods_name'] = ''; + $item['goods_image'] = ''; + $item['code'] = ''; } - $gord_id=Db::name('collection')->where('id',$item['gord_id'])->find(); - if($gord_id){ - $item['gord_name']= $gord_id['cqname']; - }else{ - $item['gord_name']= '-'; + $gord_id = Db::name('collection')->where('id', $item['gord_id'])->find(); + if ($gord_id) { + $item['gord_name'] = $gord_id['cqname']; + } else { + $item['gord_name'] = '-'; } } - + return ['count' => $count, 'lists' => $lists]; } - public static function edit($post){ - return Db::name('order')->where('id',$post['id'])->update(['consignee'=>$post['name'], - 'address'=>$post['address'], - 'mobile'=>$post['phone'], - 'pay_status'=>$post['pay_status'], - 'province'=>$post['first_category_id'], - 'city'=>$post['second_category_id'], - 'district'=>$post['third_category_id'], - 'lat'=>$post['store_longitude'], - 'lng'=>$post['store_latitude'], - 'gord_id'=>$post['gord_id'], - 'pay_status'=>1, - 'pay_zd'=>$post['pay_status'], - 'channel_id'=>$post['brand_id'], - 'order_amount'=>$post['total_amount']]); - - - - + public static function edit($post) + { + if ($post['pay_status'] == 1) { + $pay = 0; + } else { + $pay = 1; + } + $res = Db::name('order')->where('id', $post['id'])->update(['consignee' => $post['name'], + 'address' => $post['address'], + 'mobile' => $post['phone'], + 'pay_status' => $pay, + 'order_status' => $pay, + 'province' => $post['first_category_id'], + 'city' => $post['second_category_id'], + 'district' => $post['third_category_id'], + 'lat' => $post['store_longitude'], + 'lng' => $post['store_latitude'], + 'gord_id' => $post['gord_id'], + 'pay_zd' => $post['pay_status'], + 'channel_id' => $post['brand_id'], + 'order_amount' => $post['total_amount']]); + + return $res; } /** @@ -1115,29 +1127,30 @@ class OrderLogic * @throws \think\exception\PDOException * @author 张无忌(2021/2/1 18:50) */ - public static function delnumber($post, $type="get") + public static function delnumber($post, $type = "get") { - if ($type==='get') { + if ($type === 'get') { return Db::name('order')->field('id,code') - ->where(['id'=>$post['id']]) + ->where(['id' => $post['id']]) ->findOrEmpty(); } else { - + return Db::name('order') - ->where(['id'=>$post['id']]) - ->update(['code'=>$post['code']]); + ->where(['id' => $post['id']]) + ->update(['code' => $post['code']]); } } - - public static function channel_update($post){ - - $order=Db::name('order')->where('id',$post['id'])->find(); - Db::name('order')->where('id',$post['id'])->update(['channel_id'=>$post['channel_id']]); - $order_exe=Db::name('order_exe')->where('order_sn',$order['order_sn'])->find(); - if($order_exe){ - return Db::name('order_exe')->where('order_sn',$order['order_sn'])->update(['channel_id'=>$post['channel_id']]); + + public static function channel_update($post) + { + + $order = Db::name('order')->where('id', $post['id'])->find(); + Db::name('order')->where('id', $post['id'])->update(['channel_id' => $post['channel_id']]); + $order_exe = Db::name('order_exe')->where('order_sn', $order['order_sn'])->find(); + if ($order_exe) { + return Db::name('order_exe')->where('order_sn', $order['order_sn'])->update(['channel_id' => $post['channel_id']]); } return 1; - + } } \ No newline at end of file diff --git a/application/admin/view/order/add.html b/application/admin/view/order/add.html index 0b8b754b..8a8545a6 100644 --- a/application/admin/view/order/add.html +++ b/application/admin/view/order/add.html @@ -101,7 +101,7 @@
- +
@@ -186,9 +186,12 @@ var value = data.value; $('.link').hide(); switch (value) { - case '1': + case '0': // 已收款时显示选择付款 $('.page').show(); break; + case '1': // 应收款时隐藏 + $('.page').hide(); + break; case '2': $('.page').show(); $('.url-tips').show(); @@ -196,7 +199,6 @@ case '3': $('.url').show(); $('.url-tips').show(); - break; } diff --git a/application/admin/view/order/lists.html b/application/admin/view/order/lists.html index 7fd40c38..30210722 100644 --- a/application/admin/view/order/lists.html +++ b/application/admin/view/order/lists.html @@ -385,12 +385,12 @@ {{# } }}

- {{# if(d.pay_status == 0){ }} + {{# if(d.pay_status == 0 || d.pay_zd == 1){ }}

订单状态: 待支付

{{# } }} - {{# if(d.pay_status == 1){ }} + {{# if(d.pay_status == 1 && d.pay_zd == 0){ }}

订单状态: 已支付

@@ -617,6 +617,7 @@ , {field: 'order_goods', title: '商品信息', align: 'center',templet:'#goods',width:320} , {field: 'total_amount', title: '支付信息', align: 'center',templet:'#amount',width:180} , {field: 'admin_id', title: '订单归属人', align: 'center',width:180} + , {field: 'order_remarks', title: '备注信息', align: 'center',width:130} , {fixed: 'right', title: '操作', width: 160, align: 'center', toolbar: '#order-operation'} ]] , page: true diff --git a/application/api/controller/Calendar.php b/application/api/controller/Calendar.php index 53995173..9f4e92ef 100644 --- a/application/api/controller/Calendar.php +++ b/application/api/controller/Calendar.php @@ -17,20 +17,23 @@ class Calendar extends ApiBase if (!preg_match('/^\d{4}-\d{2}$/', $month)) { return $this->_error("月份格式错误,请使用格式:2026-01"); } - // 计算该月的开始和结束日期 $startDate = $month . '-01'; $endDate = date('Y-m-t', strtotime($startDate)); // 获取该月最后一天 + + $uid = $this->user_id; - // 查询该月份的所有服务数据,关联商品表和员工表 + // 查询该月份的所有服务数据,关联总订单表、商品表和员工表 $service = Db::name('order_exe') ->alias('oe') + ->join('order o', 'oe.order_sn = o.order_sn', 'INNER') ->join('goods g', 'oe.goods_id = g.id', 'LEFT') ->join('staff s', 'oe.staff_id = s.id', 'LEFT') + ->where('o.user_id', $uid) ->where('oe.date', '>=', $startDate) ->where('oe.date', '<=', $endDate) ->where('oe.abnormal', 0) - ->field('oe.staff_status,oe.date,oe.addtime,oe.start_time,oe.timeout,oe.xq,oe.staff_id,s.name as staff_name,s.onwork,s.leave,g.name as goods_name') + ->field('oe.staff_status,oe.date,oe.addtime,oe.start_time,oe.timeout,oe.xq,oe.staff_id,oe.order_sn,s.name as staff_name,s.onwork,s.leave,g.name as goods_name') ->order('oe.date asc, oe.addtime asc') ->select(); @@ -38,9 +41,10 @@ class Calendar extends ApiBase if ($service) { foreach ($service as $v) { // 如果有绑定员工,但员工状态不符合要求,则跳过 - if (!empty($v['staff_id']) && ($v['onwork'] != 1 || $v['leave'] != 1)) { - continue; - } + // 注释掉员工状态过滤,先看看是否能查询出来 + // if (!empty($v['staff_id']) && ($v['onwork'] != 1 || $v['leave'] != 1)) { + // continue; + // } // 处理服务时间 $timeRange = ''; diff --git a/application/api/controller/Payment.php b/application/api/controller/Payment.php index 6a5dec95..802db3e7 100644 --- a/application/api/controller/Payment.php +++ b/application/api/controller/Payment.php @@ -75,7 +75,9 @@ class Payment extends ApiBase if ($order['pay_status'] == Pay::ISPAID || $order['order_amount'] == 0) { $this->_success('支付成功', ['order_id' => $order['id']], 10001); } - + if ($post['order_source'] == null){ + $post['order_source'] = 1; + } $result = PaymentLogic::pay($post['from'], $order, $post['order_source']); if (false === $result) { $this->_error(PaymentLogic::getError(), ['order_id' => $order['id']], PaymentLogic::getReturnCode()); @@ -86,7 +88,6 @@ class Payment extends ApiBase * 支付成功 * 添加对应商品积分 */ - $this->_success('', $result, PaymentLogic::getReturnCode()); } diff --git a/application/api/controller/UserAddress.php b/application/api/controller/UserAddress.php index 46fd313b..bd81d4f0 100644 --- a/application/api/controller/UserAddress.php +++ b/application/api/controller/UserAddress.php @@ -75,11 +75,11 @@ class UserAddress extends ApiBase $result = $this->validate($post, 'app\api\validate\UserAddress.add'); if ($result === true) { $user_id = $this->user_id; - $adder=Db::name('user_address')->whereLike('telephone',$post['telephone'])->find(); //判断电话号码存在 - if($adder){ - $adderss=Db::name('user_address')->whereLike('telephone',$post['telephone'])->update(['user_id'=>$user_id]); - $this->_success('添加成功', $adderss); - } +// $adder=Db::name('user_address')->whereLike('telephone',$post['telephone'])->find(); //判断电话号码存在 +// if($adder){ +// $adderss=Db::name('user_address')->whereLike('telephone',$post['telephone'])->update(['user_id'=>$user_id]); +// $this->_success('添加成功', $adderss); +// } $result = UserAddressLogic::addUserAddress($user_id, $post); if ($result) { $this->_success('添加成功', $result); diff --git a/application/api/logic/GoodsCategoryLogic.php b/application/api/logic/GoodsCategoryLogic.php index f54e41ff..f54873f1 100644 --- a/application/api/logic/GoodsCategoryLogic.php +++ b/application/api/logic/GoodsCategoryLogic.php @@ -32,11 +32,11 @@ class GoodsCategoryLogic{ * @author: 2021/3/6 18:49 */ public static function categoryThirdTree($client,$type){ - $cache_key = 'goods_category_'.$client.'_'.$type; - $cache = Cache::get($cache_key); - if ($cache) { - return $cache; - } +// $cache_key = 'goods_category_'.$client.'_'.$type; +// $cache = Cache::get($cache_key); +// if ($cache) { +// return $cache; +// } // 构建查询条件 $where1 = ['is_show'=>1,'del'=>0,'level'=>1]; @@ -137,7 +137,7 @@ class GoodsCategoryLogic{ } } - Cache::set($cache_key, array_values($lists)); +// Cache::set($cache_key, array_values($lists)); return array_values($lists); } diff --git a/application/api/logic/OrderLogic.php b/application/api/logic/OrderLogic.php index 1aeaef65..1390fae4 100644 --- a/application/api/logic/OrderLogic.php +++ b/application/api/logic/OrderLogic.php @@ -1069,6 +1069,7 @@ class OrderLogic extends LogicBase case 'delivery': $where[] = ['pay_status', '=', 1]; $where[] = ['order_status', '=', 1]; + $where[] = ['refund_status', '=', 0]; break; case 'finish': $where[] = ['pay_status', '=', 1]; @@ -1133,10 +1134,10 @@ class OrderLogic extends LogicBase $list['goods_name']=$goods['name']; $list['goods_price']=$goods['min_price']; $number=Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',3)->count(); //查询订单服务次数 - $list['ordercs']=$number; + $list['ordercs'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status','<>',3)->count(); //已预约 $list['orderyjfw']= $list['number']-$number; - $list['orderdaifw'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',0)->count(); //待服务数量 - $list['orderfwzhon'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',1)->count(); //服务中数量 + $list['orderdaifw'] = $list['number']-$number; //待预约数量 + $list['orderfwzhon'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('status',3)->count(); //暂停中数量 $list['orderyiwanchen'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',3)->count(); //服务已完成 $list['showBubble']=false; $list['more']="更多"; @@ -1492,13 +1493,12 @@ class OrderLogic extends LogicBase break; } - $count =$order->where('order_sn',$order_sn) - ->count(); + $count =$order->where($where)->count(); $lists = $order->where('order_sn',$order_sn) ->where($where) ->page($page, $size) - ->order('autotime asc') + ->orderRaw('CASE WHEN staff_status = 3 THEN 1 ELSE 0 END, autotime ASC') ->select(); foreach ($lists as $list){ @@ -1518,8 +1518,6 @@ class OrderLogic extends LogicBase } $list['autotime']=date("Y-m-d",$list['autotime']); - - } $data = [ 'list' => $lists, diff --git a/application/api/logic/UserAddressLogic.php b/application/api/logic/UserAddressLogic.php index 390cca7c..5978353c 100644 --- a/application/api/logic/UserAddressLogic.php +++ b/application/api/logic/UserAddressLogic.php @@ -136,7 +136,9 @@ class UserAddressLogic 'district_id' => $post['district_id'], 'address' => $post['address'], 'is_default' => $post['is_default'], - 'createtime' => time() + 'createtime' => time(), + 'lng' => $post['latitude'], + 'lat' => $post['longitude'] ]; $result = Db::name('user_address')->insert($data); Db::commit(); @@ -175,7 +177,9 @@ class UserAddressLogic 'district_id' => $post['district_id'], 'address' => $post['address'], 'is_default' => $post['is_default'], - 'updatetime' => time() + 'updatetime' => time(), + 'lng' => $post['latitude'], + 'lat' => $post['longitude'] ]; $result = Db::name('user_address')