diff --git a/app/common/dao/store/order/StoreCartDao.php b/app/common/dao/store/order/StoreCartDao.php index e6c79202..fd054fde 100644 --- a/app/common/dao/store/order/StoreCartDao.php +++ b/app/common/dao/store/order/StoreCartDao.php @@ -79,7 +79,7 @@ class StoreCartDao extends BaseDao $query->field('product_id,stock,price,unique,sku,image,svip_price'); }, 'merchant' => function ($query) { - $query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id,credit_buy')->with(['type_names']); + $query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id,credit_buy,street_id')->with(['type_names']); } ])->select(); @@ -117,7 +117,7 @@ class StoreCartDao extends BaseDao ->append(['bc_extension_one', 'bc_extension_two']); }, 'merchant' => function (Relation $query) use ($uid) { - $query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy,settle_cycle,interest_rate') + $query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy,settle_cycle,interest_rate,type_id,street_id') ->with([ 'coupon' => function ($query) use ($uid) { $query->where('uid', $uid); diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index dba99cb6..5b102152 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -123,7 +123,8 @@ class MerchantDao extends BaseDao $query->order('is_best DESC, sales DESC,sort DESC'); } }, function ($query) use ($order) { - $query->order('is_best DESC, sort DESC,sales DESC'); + // $query->order('is_best DESC, sort DESC,sales DESC'); + $query->order('mer_id DESC'); }); return $query; } diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 97725600..36c901c6 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -5,6 +5,7 @@ namespace app\common\repositories\store\order; use app\common\dao\store\order\StoreCartDao; use app\common\model\store\order\StoreGroupOrder; use app\common\model\store\order\StoreOrder; +use app\common\model\system\merchant\Merchant; use app\common\repositories\community\CommunityRepository; use app\common\repositories\store\coupon\StoreCouponRepository; use app\common\repositories\store\coupon\StoreCouponUserRepository; @@ -69,8 +70,12 @@ class StoreOrderCreateRepository extends StoreOrderRepository //虚拟订单自定义数据 $order_extend = []; //检查商品类型, 活动商品只能单独购买 - foreach ($merchantCartList as $merchantCart) { + if($merchantCart['type_id']!=Merchant::TypeSupplyChain){ + if($merchantCart['street_id']!=$address['street_code']){ + throw new ValidateException('不支持跨区域购买,请在【我的】-【地址管理】更改后重新购买'); + } + } foreach ($merchantCart['list'] as $cart) { if ($cart['product_type']==0) { if ($cart['product']['once_min_count'] > 0 && $cart['product']['once_min_count'] > $cart['cart_num']) @@ -204,30 +209,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($deliveryStatus && !$isTake && ($merDelivery || $merTake)) { $isTake = $merDelivery ? 0 : 1; } - //加载商品数据 - foreach ($merchantCart['list'] as $cart) { - //预售订单 - if ($cart['product_type'] == 2) { - $cart->append(['productPresell', 'productPresellAttr']); - //助力订单 - } else if ($cart['product_type'] == 3) { - $cart->append(['productAssistAttr']); - //拼团订单 - } else if ($cart['product_type'] == 4) { - $cart->append(['activeSku']); - //套餐订单 - } else if ($cart['product_type'] == 10) { - $cart->append(['productDiscount', 'productDiscountAttr']); - } - //如果是预售订单 获取预售的订单的首款,尾款预售类型 - if ($order_type == 2) { - $final_price = bcadd($final_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['final_price'], 2), 2); - $presellType = $cart['productPresell']['presell_type']; - if ($presellType == 2) - $down_price = bcadd($down_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['down_price'], 2), 2); - } - } unset($cart); $enabledCoupon = !($order_type && $order_type != 2); diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index e5707842..55d842a0 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -642,7 +642,7 @@ class StoreOrderRepository extends BaseRepository if ($product_type == 98 || $product_type == 99) { $isUser = 0; } - $noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); + $noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->count(); $noPostage = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(2))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); $noDeliver = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(3))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); $noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); @@ -1808,7 +1808,7 @@ class StoreOrderRepository extends BaseRepository unset($order['takeOrderList'], $order->interest); } - return compact( 'count','list', 'where'); + return compact( 'count','list'); } public function getOrderStatusV2($order) { diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index dff4146a..669c499e 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -1691,6 +1691,8 @@ class ProductRepository extends BaseRepository ], $product['mer_id']); app()->make(SpuRepository::class)->changeStatus($id,$product->product_type); event('product.sell', ['product_id' => [$id]]); + $this->switchShow($id,$status,'is_used',0); + } /** @@ -1716,6 +1718,10 @@ class ProductRepository extends BaseRepository 'id' => $product['product_id'] ] ], $product['mer_id']); + if($data['status']==1){ + $this->switchShow($id,1,'is_used',0); + } + } $this->dao->updates($id, $data); Queue(ChangeSpuStatusJob::class, ['id' => $id, 'product_type' => $product_type]); diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index eda82bd4..38233e4e 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -293,7 +293,7 @@ class MerchantRepository extends BaseRepository */ public function getList($where, $page, $limit, $userInfo) { - $field = 'care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin,service_phone,mer_address,mer_info,credit_buy,settle_cycle,interest_rate'; + $field = 'mer_id,mini_banner,mer_name,mer_avatar,product_score,service_score,postage_score,sales,status,create_time,long,lat,mer_address,care_count,type_id'; $where['status'] = 1; $where['mer_state'] = 1; $where['is_del'] = 0; @@ -368,7 +368,7 @@ class MerchantRepository extends BaseRepository */ public function detail($id, $userInfo) { - $merchant = $this->dao->apiGetOne($id); + $merchant = $this->dao->apiGetOne($id)->hidden(['coordinates']); $merchant->append(['type_names', 'isset_certificate', 'services_type']); $merchant['care'] = false; if ($userInfo) diff --git a/app/controller/admin/ProductLibrary.php b/app/controller/admin/ProductLibrary.php index 110f4029..a506ad6d 100644 --- a/app/controller/admin/ProductLibrary.php +++ b/app/controller/admin/ProductLibrary.php @@ -150,6 +150,16 @@ class ProductLibrary extends BaseController $res = Db::name('product_library')->insert($data); if ($res) { + $group_id=Db::name('system_group')->where('group_key','product_caiji_count')->value('group_id'); + if($group_id){ + $find=Db::name('system_group_data')->where('group_id',$group_id)->whereDay('create_time')->find(); + if($find){ + $count=json_decode($find['value'],true)['count']+1; + Db::name('system_group_data')->where('group_data_id',$find['group_data_id'])->update(['value'=>json_encode(['count'=>$count])]); + }else{ + Db::name('system_group_data')->insert(['group_id'=>$group_id,'value'=>'{"count":1}','create_time'=>date('Y-m-d H:i:s')]); + } + } return app('json')->success('添加成功'); } else { throw new \think\exception\ValidateException('添加失败'); diff --git a/app/controller/api/Statistics.php b/app/controller/api/Statistics.php index f1ae9f44..4d39af60 100644 --- a/app/controller/api/Statistics.php +++ b/app/controller/api/Statistics.php @@ -34,14 +34,14 @@ class Statistics extends BaseController if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { return app('json')->fail('end_time:格式错误'); } - $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + $where[] = ['create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; if (isset($parmas['responsible_area']) && $parmas['responsible_area'] != '') { - $where[] = [$type,'in',explode(',', $parmas['responsible_area'])]; + $where[] = [$type, 'in', explode(',', $parmas['responsible_area'])]; } - $where[]=['is_del','=',0]; - $where[]=['status','=',1]; - $count=Db::name('merchant')->where($where)->count(); - return app('json')->success(['count'=>$count]); + $where[] = ['is_del', '=', 0]; + $where[] = ['status', '=', 1]; + $count = Db::name('merchant')->where($where)->count(); + return app('json')->success(['count' => $count]); } /** @@ -60,14 +60,14 @@ class Statistics extends BaseController if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { return app('json')->fail('mer_intention_id:格式错误'); } - $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; - $where[] = ['mer_id','=',$parmas['mer_intention_id']]; - $where[]=['mer_status','=',1]; - $where[]=['status','=',1]; - $where[]=['is_used','=',1]; - $where[]=['is_show','=',1]; - $count=Db::name('store_product')->where($where)->count(); - return app('json')->success(['count'=>$count]); + $where[] = ['create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; + $where[] = ['mer_id', '=', $parmas['mer_intention_id']]; + $where[] = ['mer_status', '=', 1]; + $where[] = ['status', '=', 1]; + $where[] = ['is_used', '=', 1]; + $where[] = ['is_show', '=', 1]; + $count = Db::name('store_product')->where($where)->count(); + return app('json')->success(['count' => $count]); } /** @@ -86,33 +86,33 @@ class Statistics extends BaseController if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { return app('json')->fail('mer_intention_id:格式错误'); } - $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; - $where[] = ['mer_id','=',$parmas['mer_intention_id']]; - $count=Db::name('store_product_stock')->where($where)->count(); - return app('json')->success(['count'=>$count]); + $where[] = ['create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; + $where[] = ['mer_id', '=', $parmas['mer_intention_id']]; + $count = Db::name('store_product_stock')->where($where)->count(); + return app('json')->success(['count' => $count]); } /** * 商品列表 */ - public function ProductList(){ + public function ProductList() + { $parmas = $this->request->param(); if (!isset($parmas['page']) || $parmas['page'] == '') { return app('json')->fail('page:格式错误'); } - $where[]=['mer_status','=',1]; - $where[]=['status','=',1]; - $where[]=['is_used','=',1]; - $where[]=['is_show','=',1]; - if (isset($parmas['keyword']) &&$parmas['keyword'] != '') { - $where[] = ['store_name','like','%'.$parmas['keyword'].'%']; + $where[] = ['mer_status', '=', 1]; + $where[] = ['status', '=', 1]; + $where[] = ['is_used', '=', 1]; + $where[] = ['is_show', '=', 1]; + if (isset($parmas['keyword']) && $parmas['keyword'] != '') { + $where[] = ['store_name', 'like', '%' . $parmas['keyword'] . '%']; } - $list=Db::name('store_product')->where($where)->page($parmas['page']) - ->field('product_id,store_name,image,price') - ->limit(10)->select(); - return app('json')->success(['page'=>$parmas['page'],'data'=>$list]); - + $list = Db::name('store_product')->where($where)->page($parmas['page']) + ->field('product_id,store_name,image,price') + ->limit(10)->select(); + return app('json')->success(['page' => $parmas['page'], 'data' => $list]); } /** @@ -124,17 +124,17 @@ class Statistics extends BaseController if (isset($parmas['type']) && $parmas['type'] != '') { switch ($parmas['type']) { case 200: - $where[] = ['p.source','=',200]; + $where[] = ['p.source', '=', 200]; break; case 300: - $where[] = ['p.source','=',300]; + $where[] = ['p.source', '=', 300]; break; default: return app('json')->fail('type:格式错误'); break; } } else { - $where[] = ['p.source','=',0]; + $where[] = ['p.source', '=', 0]; } if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { return app('json')->fail('start_time:格式错误'); @@ -149,17 +149,17 @@ class Statistics extends BaseController return app('json')->fail('goods_id:格式错误'); } - $where[]=['p.create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; - $where[] = ['p.product_id','in',explode(',', $parmas['goods_id'])]; - $where[] = ['p.is_refund','=',0]; - $count=Db::name('store_order_product')->alias('p') - ->where($where) - ->join('store_order o','o.mer_id='.$parmas['mer_intention_id'].' and o.paid=1 and o.is_del=0') - ->sum('p.total_price'); - return app('json')->success(['procure_amount'=>$count]); + $where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; + $where[] = ['p.product_id', 'in', explode(',', $parmas['goods_id'])]; + $where[] = ['p.is_refund', '=', 0]; + $count = Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o', 'o.mer_id=' . $parmas['mer_intention_id'] . ' and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + return app('json')->success(['procure_amount' => $count]); } - /** + /** * 镇一般商户采购金额和销售金额统计 */ public function SupplyChainStreetProductPriceCount() @@ -168,17 +168,17 @@ class Statistics extends BaseController if (isset($parmas['type']) && $parmas['type'] != '') { switch ($parmas['type']) { case 200: - $where[] = ['p.source','=',200]; + $where[] = ['p.source', '=', 200]; break; case 300: - $where[] = ['p.source','=',300]; + $where[] = ['p.source', '=', 300]; break; default: return app('json')->fail('type:格式错误'); break; } } else { - $where[] = ['p.source','=',0]; + $where[] = ['p.source', '=', 0]; } if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { return app('json')->fail('start_time:格式错误'); @@ -190,22 +190,88 @@ class Statistics extends BaseController return app('json')->fail('goods_id:格式错误'); } if (isset($parmas['responsible_area']) && $parmas['responsible_area'] != '') { - $area[] = ['street_id','in',explode(',', $parmas['responsible_area'])]; - }else{ + $area[] = ['street_id', 'in', explode(',', $parmas['responsible_area'])]; + } else { return app('json')->fail('responsible_area:格式错误'); } - $merchant=Db::name('merchant')->where($area)->column('mer_id'); - if(!$merchant){ + $merchant = Db::name('merchant')->where($area)->column('mer_id'); + if (!$merchant) { return app('json')->fail('查询商户为空'); } - $where[]=['p.create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; - $where[] = ['p.product_id','in',explode(',', $parmas['goods_id'])]; - $where[] = ['p.is_refund','=',0]; - $count=Db::name('store_order_product')->alias('p') - ->where($where) - ->join('store_order o','o.mer_id in ('.implode(',',$merchant).') and o.paid=1 and o.is_del=0') - ->sum('p.total_price'); - return app('json')->success(['procure_amount'=>$count]); + $where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; + $where[] = ['p.product_id', 'in', explode(',', $parmas['goods_id'])]; + $where[] = ['p.is_refund', '=', 0]; + $count = Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o', 'o.mer_id in (' . implode(',', $merchant) . ') and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + return app('json')->success(['procure_amount' => $count]); } + + /** + * 查询镇农科公司负责片区内的种养殖商户和供应链商户交易额 + *暂无种养殖商户分类 + */ + public function SupplyChainBreedingStreetProductCount() + { + $parmas = $this->request->param(); + + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + if (!isset($parmas['responsible_area']) || $parmas['responsible_area'] == '') { + return app('json')->fail('responsible_area:格式错误'); + } + // if (!isset($parmas['type']) || $parmas['type'] == '') { + // return app('json')->fail('type:格式错误'); + // } + $area[] = ['street_id', 'in', explode(',', $parmas['responsible_area'])]; + $area[] = ['type_id', '=',17]; + + $merchant = Db::name('merchant')->where($area)->column('mer_id'); + if (!$merchant) { + return app('json')->fail('查询商户为空'); + } + $where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; + $where[] = ['p.is_refund', '=', 0]; + $count = Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o', 'o.mer_id in (' . implode(',', $merchant) . ') and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + return app('json')->success(['trade_amount' => $count]); + } + + /** + * 查询手机号用户的交易金额 + */ + public function StoreOrderUserTradeAmount() + { + $parmas = $this->request->param(); + + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + if (!isset($parmas['phone']) || $parmas['phone'] == '') { + return app('json')->fail('phone:格式错误'); + } + $user_id= Db::name('user')->where('account',$parmas['phone'])->value('uid'); + if(!$user_id){ + return app('json')->fail('查询的手机号用户不存在'); + } + $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + $where[]=['paid','=',1]; + $where[]=['status','<>',-1]; + $where[]=['uid','=',$user_id]; + $count=Db::name('store_order') + ->where($where) + ->sum('pay_price'); + return app('json')->success(['trade_amount'=>$count]); + } } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 8bfa340e..8097dc02 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -29,6 +29,9 @@ use app\common\repositories\system\merchant\MerchantRepository as repository; use think\facade\Db; use think\facade\Queue; use app\common\model\system\merchant\Merchant as MerchantModel; +use crmeb\services\QrcodeService; +use app\common\repositories\system\attachment\AttachmentRepository; +use app\common\repositories\user\UserBillRepository; class Merchant extends BaseController { @@ -57,8 +60,7 @@ class Merchant extends BaseController [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id', 'type_code', 'is_trader', 'street_id', 'credit_buy']); if (empty($where['type_id'])) { - //$where['type_id'] = [MerchantModel::TypeCloudWarehouse, MerchantModel::TypeStore, MerchantModel::TypeSupplyChain, MerchantModel::TypePlatform]; - $where['type_id'] = Db::name('MerchantType')->where('is_allow_apply', 1)->where('type_code', '<>', MerchantModel::TypeCode['TypeSupplyChain'])->column('mer_type_id'); + $where['type_id'] =[10,17]; } return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo)); } @@ -124,7 +126,27 @@ class Merchant extends BaseController { if(!$this->repository->merExists($id)) return app('json')->fail('店铺已打烊'); - $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id)); + if ($this->request->param('type') == 'routine') { + $url= $this->repository->routineQrcode(intval($id)); + }elseif($this->request->param('type') == 'app'){ + $attachmentRepository = app()->make(AttachmentRepository::class); + $name='merchant_code_'.$id.'.png'; + $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]); + if($imageInfo){ + $url=$imageInfo['attachment_src']; + }else{ + $info = app()->make(QrcodeService::class)->getQRCodePath(systemConfig('site_url').'pages/store/home/index?id=' . $id, $name); + $attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $id, [ + 'attachment_category_id' => 0, + 'attachment_name' => $info['name'], + 'attachment_src' => $info['dir'] + ]); + $url=$info['dir']; + } + } + else{ + $url= $this->repository->wxQrcode(intval($id)); + } return app('json')->success(compact('url')); } @@ -220,6 +242,11 @@ class Merchant extends BaseController if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine')) return app('json')->fail('开启店铺前请先完成微信子商户入驻'); } + if($data['long']!=''&& $data['lat']!=''){ + $long=$data['long']; + $lat=$data['lat']; + Db::query("UPDATE eb_merchant SET coordinates = ST_GeomFromText('POINT($long $lat)') WHERE mer_id = $id"); + } Db::name('merchant')->where('mer_id',$id)->update($data); Queue::push(ChangeMerchantStatusJob::class, $id); @@ -285,10 +312,14 @@ class Merchant extends BaseController $extract_minimum_num = systemConfig('extract_minimum_num'); $_line = bcsub($merchant->mer_money,$extract_minimum_line,2); $_extract = ($_line < 0) ? 0 : $_line; + $merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($merId); + $data = [ 'mer_id' => $merchant->mer_id,//商户id 'mer_name' => $merchant->mer_name,//商户名称 'mer_money' => $merchant->mer_money,//商户余额 + 'lock_money' => $merLockMoney,//冻结金额 + 'lock_time' => systemConfig('mer_lock_time'),//冻结金额 'extract_minimum_line' => $extract_minimum_line,//提现最低额度 'extract_minimum_num' => $extract_minimum_num,//提现最低次数 'extract_money' => $_extract,//可提现金额 diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 3d4ae0d7..46e60b6b 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -108,22 +108,14 @@ class StoreOrder extends BaseController if ($cartProductType == 0 && count($deliveryWay) == 0) { $userAddressCode = ($address['province_code'] ?? '') . ',' . ($address['city_code'] ?? '') . ',' . ($address['district_code'] ?? '') . ',' . ($address['street_code'] ?? '') . ',' . ($address['village_code'] ?? '') . ',' . ($address['brigade_id'] ?? 0); $getUrl = env('LOGISTICS_HOST_URL') . '/api/hasCourier?user_address_code=' . $userAddressCode; - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $getUrl); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 2); - $hasCourierData = curl_exec($ch); - curl_close($ch); - if (!empty($hasCourierData) && is_string($hasCourierData)) { - $courierData = json_decode($hasCourierData, true); - if (empty($courierData['code']) || $courierData['code'] != 1) { - throw new ValidateException('该收货区域未设置快递员'); - } - } + $client = new \GuzzleHttp\Client(); + $response = $client->request('GET', $getUrl); + $courierData = json_decode($response->getBody(), true); + if (empty($courierData['code']) || $courierData['code'] != 1) { + throw new ValidateException('该收货区域未设置快递员'); + } } } - $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) { return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post); }); diff --git a/app/controller/api/store/order/StoreOrderBehalf.php b/app/controller/api/store/order/StoreOrderBehalf.php index dd3a6523..7c08dc38 100644 --- a/app/controller/api/store/order/StoreOrderBehalf.php +++ b/app/controller/api/store/order/StoreOrderBehalf.php @@ -30,6 +30,7 @@ use crmeb\services\LockService; use think\facade\Db; use think\App; use think\facade\Log; +use app\common\dao\store\order\StoreOrderDao; /**代发订单 * Class StoreOrder @@ -43,16 +44,18 @@ class StoreOrderBehalf extends BaseController * @var StoreOrderRepository */ protected $repository; + protected $dao; /** * StoreOrder constructor. * @param App $app * @param StoreOrderRepository $repository */ - public function __construct(App $app, StoreOrderRepository $repository) + public function __construct(App $app, StoreOrderRepository $repository,StoreOrderDao $dao) { parent::__construct($app); $this->repository = $repository; + $this->dao = $dao; } /** * @return mixed @@ -65,14 +68,23 @@ class StoreOrderBehalf extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $status = $this->request->param('status',1); - + $status = $this->request->param('status','all'); $uid = $this->request->userInfo()['uid']; $mer_id = Db::name('store_service')->where('uid', $uid)->where('is_del', 0)->value('mer_id'); if ($mer_id) { - $column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status', $status)->page($page)->limit($limit)->column('order_id'); + if($status=='all'){ + $where['status']=['>=',0]; + }else{ + $where['status']=['=',$status]; + } + $column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id'); if ($column) { $where['order_id'] = $column; + if($status==0){ + $where['status']=2; + }elseif($status==1){ + $where['status']=3; + } return app('json')->success($this->repository->getList($where, 1, 100)); } } @@ -101,12 +113,12 @@ class StoreOrderBehalf extends BaseController */ public function logisticsCode($id) { - $status = $this->request->param('status',1); + // $status = $this->request->param('status',1); $order_id = $this->request->param('order_id',0); $uid = $this->request->userInfo()['uid']; $mer_id = Db::name('store_service')->where('uid', $uid)->where('is_del', 0)->value('mer_id'); if ($mer_id) { - $order_id = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status', $status)->where('order_id',$order_id)->value('order_id'); + $order_id = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status','>=',0)->where('order_id',$order_id)->value('order_id'); if ($order_id) { $order = $this->repository->getWhere(['order_id' => $id,'is_del' => 0]); @@ -115,4 +127,25 @@ class StoreOrderBehalf extends BaseController } return app('json')->fail('信息有误:请联系官方人员'); } + + /**代发订单统计 + * @return mixed + * @author xaboy + * @day 2020/6/10 + */ + public function number() + { + $uid = $this->request->userInfo()['uid']; + $mer_id = Db::name('store_service')->where('uid', $uid)->where('is_del', 0)->value('mer_id'); + if ($mer_id) { + $noPostage = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status',0) + ->join('store_order', 'store_order.status = 0') + ->count(); + $noDeliver = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status',1) + ->join('store_order', 'store_order.status = 1') + ->count(); + + } + return app('json')->success(compact('noDeliver', 'noPostage',)); + } } diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index dc63ac0f..7610742c 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -92,18 +92,12 @@ class CloudWarehouse extends BaseController // } /** - * 云仓商品列表 + * type_id 13云仓商品列表 * @return mixed */ - public function index($street_code, $page_num = 1, $category_id = 0) + public function index($street_code, $page = 1, $category_id = 0,$location='') { - if ($category_id == 0) { - return app('json')->fail('分类id不能为0'); - } - $cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('category_id', $category_id)->where('status', 1)->page($page_num)->column('product_id'); - if (!$cloud_product) { - return app('json')->success(['count' => 0, 'list' => []]); - } + $cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->page($page)->column('product_id'); $where = [ 'is_show' => 1, 'is_used' => 1, @@ -111,6 +105,10 @@ class CloudWarehouse extends BaseController 'is_del' => 0, 'mer_status' => 1, ]; + if (!$cloud_product && $category_id==0) { + + return app('json')->success(['count' => 0, 'list' => []]); + } $count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count(); $select = Db::name('store_product')->whereIn('product_id', $cloud_product)->where($where) ->withAttr('merchant', function ($value, $data) { @@ -132,8 +130,7 @@ class CloudWarehouse extends BaseController */ public function town() { - // 除了市级供应链都可以查询 - $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page_num']); + $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page']); $search = [ 'street_id' => $params['street_code'], 'type_id' => Merchant::TypeTownSupplyChain, @@ -146,8 +143,8 @@ class CloudWarehouse extends BaseController } $merchantIds = $this->merchantDao->search($search)->column('mer_id'); [$page, $limit] = $this->getPage(); - if (isset($params['page_num']) && $params['page_num'] != '') { - $page = $params['page_num']; + if (isset($params['page']) && $params['page'] != '') { + $page = $params['page']; } if (empty($merchantIds)) { return app('json')->success(['count' => 0, 'list' => []]); diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index e05b2658..e5e4a775 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -42,8 +42,6 @@ class StoreSpu extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - // 除了市级供应链都可以查询 - $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', (string)Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id'); $where = $this->request->params([ 'keyword', 'cate_id', @@ -59,12 +57,22 @@ class StoreSpu extends BaseController 'common', 'is_trader', 'product_ids', - 'mer_id' + 'mer_id', + 'type_id', + 'street_id' ]); + if($where['type_id']){ + $arr=['status' => 1, 'mer_state' => 1, 'is_del' => 0]; + if($where['street_id']){ + $arr['street_id']=$where['street_id']; + } + $where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', explode(',', $where['type_id']))->where($arr)->column('mer_id'); + } + unset($where['type_id'],$where['street_id']); + $where['is_gift_bag'] = 0; $where['product_type'] = 0; $where['order'] = $where['order'] ?: 'star'; - $where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', implode(',', $typeIdArray ?? []))->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id'); if ($where['is_trader'] != 1) unset($where['is_trader']); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); return app('json')->success($data); @@ -170,6 +178,7 @@ class StoreSpu extends BaseController { [$page, $limit] = $this->getPage(); $where = $this->request->params(['common','mer_id']); + $params = $this->request->params(['location']); $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id'); $where['is_gift_bag'] = 0; //1:星级 @@ -196,8 +205,18 @@ class StoreSpu extends BaseController } $where['product_type'] = 0; $where['is_stock'] = 1; - $where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', implode(',', $typeIdArray ??[])) - ->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id'); + if($params['location']!=''){ + [$lon,$lat]=explode(',',$params['location']); + $select=Db::query("select mer_id,ST_Distance(coordinates, POINT($lon,$lat)) AS distance from eb_merchant where coordinates !='' and type_id IN ('10', '17') and is_del=0 and mer_state=1 ORDER BY distance LIMIT 100;"); + $arr=[]; + foreach($select as $k=>$v){ + $arr[]=$v['mer_id']; + } + if($arr){ + $where['mer_ids'] =$arr; + + } + } $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); return app('json')->success($data); } diff --git a/app/controller/api/user/Zhibo.php b/app/controller/api/user/Zhibo.php index 46758399..92904116 100644 --- a/app/controller/api/user/Zhibo.php +++ b/app/controller/api/user/Zhibo.php @@ -40,7 +40,7 @@ class Zhibo extends BaseController return app('json')->fail('live_stream_id, master_id, live_name, gift_id, gift_name, gift_num, amount 参数不能为空'); } if ($params['amount'] > $user['now_money']) { - return app('json')->fail('余额不足'); + return app('json')->fail('余额不足', ['balance_status' => -1]); } try { Db::transaction(function () use ($user, $params) { diff --git a/app/listener/paySuccess.php b/app/listener/paySuccess.php index 18360221..bca1c291 100644 --- a/app/listener/paySuccess.php +++ b/app/listener/paySuccess.php @@ -44,7 +44,7 @@ class paySuccess 'master_mer_id'=>$order['mer_id'], 'mer_id'=>$merchant_two['mer_id'], 'order_id'=>$order['order_id'], - 'status'=>1 + 'status'=>0 ]; Db::name('store_order_behalf')->insert($datas); } diff --git a/crmeb/services/QrcodeService.php b/crmeb/services/QrcodeService.php index cd850cc1..f07ffab7 100644 --- a/crmeb/services/QrcodeService.php +++ b/crmeb/services/QrcodeService.php @@ -159,7 +159,6 @@ class QrcodeService */ public function getRoutineQrcodePath($namePath, $page, $data) { - try { $imageInfo = app()->make(AttachmentRepository::class)->getWhere(['attachment_name' => $namePath]); if (!$imageInfo) { @@ -182,7 +181,9 @@ class QrcodeService 'attachment_src' => $imageInfo['dir'] ]); $url = $imageInfo['dir']; - } else $url = $imageInfo['attachment_src']; + }else{ + $url = $imageInfo['attachment_src']; + } return $url; } catch (\Throwable $e) { return false; diff --git a/route/api.php b/route/api.php index 7d5ec25d..3e44955e 100644 --- a/route/api.php +++ b/route/api.php @@ -348,6 +348,7 @@ Route::group('api/', function () { Route::group('behalf_admin', function () { Route::get('/order_list', '/lst'); Route::get('/code', '/logisticsCode'); + Route::get('/number', '/number'); })->prefix('api.store.order.StoreOrderBehalf'); //管理员申请转账 Route::get('admin/:merId/apply', 'api.store.merchant.Merchant/apply'); @@ -701,6 +702,8 @@ Route::group('api/', function () { Route::get('product_list', '/ProductList'); Route::get('supply_chain_product_price_count', '/SupplyChainProductPriceCount'); Route::get('supply_chain_street_product_price_count', '/SupplyChainStreetProductPriceCount'); + Route::get('supply_chain_breeding_street_product_count', '/SupplyChainBreedingStreetProductCount'); + Route::get('store_order_user_trade_amount', '/StoreOrderUserTradeAmount'); })->prefix('api.Statistics'); //滑块验证码