diff --git a/app/common/dao/store/order/StoreCartDao.php b/app/common/dao/store/order/StoreCartDao.php index 581cd869..d4a1dc5c 100644 --- a/app/common/dao/store/order/StoreCartDao.php +++ b/app/common/dao/store/order/StoreCartDao.php @@ -29,7 +29,8 @@ class StoreCartDao extends BaseDao const SOURCE_STORE_CLOUD = 101; //店铺内云商品 const SOURCE_CLOUD = 102; //云仓内店铺商品 - const SOURCE_COMMUNITY_RESALE = 201; //转售商品 + const SOURCE_COMMUNITY_RESALE = 201; //转售商品 + const SOURCE_COMMUNITY_ENTRUST = 202; //委托商品 protected function getModel(): string { diff --git a/app/common/dao/system/AppUpdateDao.php b/app/common/dao/system/AppUpdateDao.php new file mode 100644 index 00000000..78db6032 --- /dev/null +++ b/app/common/dao/system/AppUpdateDao.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\system; + + +use app\common\dao\BaseDao; +use app\common\model\BaseModel; +use app\common\model\system\AppUpdate; +use think\db\exception\DbException; + +/** + * Class AppUpdateDao + * @package app\common\dao\system + * @author xaboy + * @day 2020-04-24 + */ +class AppUpdateDao extends BaseDao +{ + + /** + * @return BaseModel + * @author xaboy + * @day 2020-03-30 + */ + protected function getModel(): string + { + return AppUpdate::class; + } + + +} diff --git a/app/common/model/community/Community.php b/app/common/model/community/Community.php index fa77d9b2..066b0672 100644 --- a/app/common/model/community/Community.php +++ b/app/common/model/community/Community.php @@ -16,6 +16,7 @@ namespace app\common\model\community; use app\common\model\BaseModel; use app\common\model\store\product\Spu; use app\common\model\store\Resale; +use app\common\model\store\Entrust; use app\common\model\system\Relevance; use app\common\model\user\User; use app\common\repositories\system\RelevanceRepository; @@ -177,4 +178,9 @@ class Community extends BaseModel return $this->hasMany(Resale::class, 'community_id','community_id'); } + public function entrust() + { + return $this->hasMany(Entrust::class, 'community_id','community_id'); + } + } diff --git a/app/common/model/store/order/StoreCart.php b/app/common/model/store/order/StoreCart.php index 58d9263b..1a2ae6bc 100644 --- a/app/common/model/store/order/StoreCart.php +++ b/app/common/model/store/order/StoreCart.php @@ -155,7 +155,7 @@ class StoreCart extends BaseModel 'activity_id' => $this->source_id, 'product_type' => $this->product_type, ]; - if ($this->product_type == 98) { + if ($this->product_type == 98 || $this->product_type == 99) { $where['product_id'] = $this->product_id; } } else { diff --git a/app/common/model/store/product/Product.php b/app/common/model/store/product/Product.php index 52dac139..c1a46889 100644 --- a/app/common/model/store/product/Product.php +++ b/app/common/model/store/product/Product.php @@ -43,6 +43,7 @@ class Product extends BaseModel const TYPE_NORMAL = 0; //普通商品 const TYPE_PURCHASE = 98; //采购商品 + const TYPE_ENTRUST = 99; //委托商品 /** * @Author:Qinii diff --git a/app/common/model/system/AppUpdate.php b/app/common/model/system/AppUpdate.php new file mode 100644 index 00000000..e9b57ba2 --- /dev/null +++ b/app/common/model/system/AppUpdate.php @@ -0,0 +1,20 @@ +dao->getPk() => $id, + 'is_del' => 0 + ]; + $community = $this->dao->getSearch($where)->with('entrust')->find()->toArray(); + if (empty($community) || $community['is_sale'] != 0) { + throw new ValidateException('委托数据不存在或已售出'); + } + if (empty($community['entrust'])) { + throw new ValidateException('委托数据不存在'); + } + StoreCart::startTrans(); + try { + /** @var StoreCartRepository $cartRepo */ + $cartRepo = app()->make(StoreCartRepository::class); + $cartIds = []; + foreach ($community['entrust'] as $item) { + $data = [ + 'uid' => $uid, + 'mer_id' => $item['mer_id'], + 'product_type' => 99, + 'product_id' => $item['product_id'], + 'product_attr_unique' => $item['product_attr_unique'], + 'cart_num' => $item['number'], + 'source' => StoreCartDao::SOURCE_COMMUNITY_ENTRUST, + 'source_id' => $community['community_id'], + ]; + $cart = $cartRepo->create($data); + $cartIds[] = $cart['cart_id']; + } + if (empty($cartIds)) { + throw new ValidateException('加入购物车出错'); + } + StoreCart::commit(); + return $cartIds; + } catch (\Exception $exception) { + StoreCart::rollback(); + throw new ValidateException('下单出错'); + } + } + public function saleOrCancel($id, $status = 1) { $where = [ diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 995b4c49..946bfd57 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -68,6 +68,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository //虚拟订单自定义数据 $order_extend = []; //检查商品类型, 活动商品只能单独购买 + foreach ($merchantCartList as $merchantCart) { foreach ($merchantCart['list'] as $cart) { if ($cart['product_type']==0) { @@ -83,7 +84,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository throw new ValidateException('[超出限购总数:'. $cart['product']['once_max_count'].']'.mb_substr($cart['product']['store_name'],0,10).'...'); } } - if ($cart['product_type'] > 0) $order_type = $cart['product_type']; if ($cart['product_type']<=97 &&$cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) { throw new ValidateException('活动商品必须单独购买'); @@ -97,8 +97,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } - if ($order_type == 98 && count($merchantCartList) > 1) { - throw new ValidateException('采购商品不支持跨店购买'); + if (($order_type == 98 || $order_type == 99) && count($merchantCartList) > 1) { + throw new ValidateException('采购、委托商品不支持跨店购买'); } $community = []; if ($order_type == 98) { @@ -138,7 +138,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository } $orderDeliveryStatus = true; $order_svip_discount = 0; - // 循环计算每个店铺的订单数据 + // 循环计算每个店铺的订单数据 委托商品是否设置收货方式 ? foreach ($merchantCartList as &$merchantCart) { if ($order_type == 98 && !empty($deliverMethodArray)) { $merchantCart['delivery_way'] = $deliverMethodArray; @@ -172,7 +172,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository $product_cart = []; foreach ($merchantCart['list'] as $k => $cart) { - //处理转售送货方式 if ($order_type == 98) { $merchantCart['list'][$k]['product']['delivery_way'] = $cart['product']['delivery_way'] = $deliverMethod ?? ''; } @@ -247,7 +246,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository } $svip_discount = 0; $realPrice = $this->cartByPrice($cart); - if ($cart['product_type'] == 98) { + if ($cart['product_type'] == 98 || $cart['product_type'] == 99) { $cart['product']['price'] = $realPrice; $cart['productAttr']['price'] = $realPrice; $cart['productAttr']['stock'] = $cart['cart_num']; @@ -961,7 +960,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($orderType == 0 && $pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { throw new ValidateException('该商品不支持先货后款'); } - if (!in_array($orderType, [0, 98]) && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { + if (!in_array($orderType, [0, 98, 99]) && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { throw new ValidateException('活动商品请单独购买'); } @@ -986,8 +985,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } - if ($orderType == 98 && count($merchantCartList) > 1) { - throw new ValidateException('采购商品不支持跨店购买'); + if (($orderType == 98 || $orderType == 99) && count($merchantCartList) > 1) { + throw new ValidateException('采购、委托商品不支持跨店购买'); } if ($hasTake) { app()->make(UserAddressValidate::class)->scene('take')->check($post); diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index d66c2279..0fcd0c67 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -18,6 +18,7 @@ use app\common\model\store\order\StoreOrderInterest; use app\common\model\store\order\StoreRefundOrder; use app\common\model\store\product\PurchaseRecord; use app\common\model\user\User; +use app\common\model\system\merchant\Merchant; use app\common\repositories\BaseRepository; use app\common\repositories\delivery\DeliveryOrderRepository; use app\common\repositories\store\coupon\StoreCouponRepository; @@ -248,6 +249,17 @@ class StoreOrderRepository extends BaseRepository //更新助力状态 app()->make(ProductAssistSetRepository::class)->changStatus($order->orderProduct[0]['activity_id']); } + + //更新委托订单处理 + if ($order->activity_type == 99) { + $cartIdArray = explode(',', $order->cart_id); + $ecartList = Db::name('store_cart')->whereIn('cart_id', $cartIdArray)->select(); + foreach($ecartList as $ecart) { + if (!empty($ecart['source_id'])) { + Db::name('community')->where('community_id', $ecart['source_id'])->update(['entrust_order_id' => $order->order_id ?? 0]); + } + } + } // 订单的类型 0 发货 1 自提 if ($order->order_type == 1 && $order->status != 10) { @@ -540,6 +552,18 @@ class StoreOrderRepository extends BaseRepository } else { return $cart['productAttr']['price']; } + // 更新委托价格 + } else if ($cart['product_type'] == '99') { + if ($cart['source_id'] > 0) { + $price = Db::name('entrust')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); + if ($price) { + return $price; + } else { + throw new ValidateException('委托商品数据异常'); + } + } else { + return $cart['productAttr']['price']; + } } else { return $cart['productAttr']['price']; } @@ -563,6 +587,14 @@ class StoreOrderRepository extends BaseRepository } else { return $cart['productAttr']['price']; } + // 更新委托价格 + } else if ($cart['product_type'] == '99') { + $price = Db::name('entrust')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); + if ($price) { + return $price; + } else { + return $cart['productAttr']['price']; + } } else { return $cart['productAttr']['price']; } @@ -586,10 +618,10 @@ class StoreOrderRepository extends BaseRepository */ public function userOrderNumber(int $uid, $product_type=0) { - //activity_type:0普通订单 98 采购订单 + //activity_type:0普通订单 98采购订单 99委托商品 //$noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type); $isUser = 1; - if ($product_type == 98) { + 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(); @@ -2458,9 +2490,11 @@ class StoreOrderRepository extends BaseRepository $mer_cate['level']=1; $mer_cate_id=Db::name('store_category')->insertGetId($mer_cate); } - $type=Db::name('merchant')->where('mer_id',$merId)->value('type_id'); + // $type=Db::name('merchant')->where('mer_id',$merId)->value('type_id'); + $typeCode=Db::name('merchant_type')->where('mer_type_id',$merId)->value('type_code'); $product_type=0; - if ($type==12){ + // if ($type==12){ + if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $product_type=98;//供应链 } foreach ($data as $datum) { diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 8dc950aa..e0bebf87 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -240,9 +240,9 @@ class ProductRepository extends BaseRepository $settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0,$data['mer_id']); $settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $result->product_id, $data['mer_id']); $settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id); - if (in_array($productType, [0, 98])) app()->make(ParameterValueRepository::class)->create($result->product_id, $data['params'] ?? [],$data['mer_id']); + if (in_array($productType, [0, 98, 99])) app()->make(ParameterValueRepository::class)->create($result->product_id, $data['params'] ?? [],$data['mer_id']); $this->save($result->product_id, $settleParams, $content,$product,$productType); - if (in_array($productType, [0, 1,98])) { + if (in_array($productType, [0, 1, 98, 99])) { if ($productType == 1) { //秒杀商品 $dat = $this->setSeckillProduct($data); $dat['product_id'] = $result->product_id; @@ -316,7 +316,7 @@ class ProductRepository extends BaseRepository $settleParams['attr'] = $this->setAttr($data['attr'], $id); $data['price'] = $settleParams['data']['price']; unset($data['attrValue'],$data['attr'],$data['mer_cate_id']); - $ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type',[0, 98])->find(); + $ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type',[0, 98, 99])->find(); Db::transaction(function () use ($id, $data, $settleParams,$ret) { $this->save($id, $settleParams, null, [], 0); app()->make(SpuRepository::class)->update($ret->spu_id,['price' => $data['price']]); @@ -799,7 +799,7 @@ class ProductRepository extends BaseRepository break; } if ($productType == 0) { - $where[] = empty($merId) ? ['product_type', 'in', [0, 98]] : ['product_type', 'in', [0]]; + $where[] = empty($merId) ? ['product_type', 'in', [0, 98, 99]] : ['product_type', 'in', [0]]; if (!$merId) $where['is_gift_bag'] = 0; } if ($productType == 1) { @@ -1170,6 +1170,7 @@ class ProductRepository extends BaseRepository switch ($res['product_type']) { case 0: case 98: + case 99: $append[] = 'max_integral'; $append[] = 'show_svip_info'; break; @@ -2171,6 +2172,7 @@ class ProductRepository extends BaseRepository { case 0: case 98: + case 99: return $this->apiProductDetail(['product_id' => $data['id']], $data['product_type'], 0); break; case 1: @@ -2314,7 +2316,7 @@ class ProductRepository extends BaseRepository $stockIn = $params['number'] ?? 0; $price = $params['price'] ?? 0; if (!empty($params['order_id'])) { - //采购订单导入 + //采购、委托订单导入 $orderMerId = StoreOrder::where('order_id', $params['order_id'])->value('mer_id'); $orderProduct = StoreOrderProduct::where('order_id', $params['order_id'])->where('product_id', $params['order_product_id'])->where('product_sku', $params['order_unique'])->find(); if (empty($orderProduct) || $orderProduct->is_imported == 1) { @@ -2323,6 +2325,10 @@ class ProductRepository extends BaseRepository $stockIn = $orderProduct['product_num'] ?? 0; $price = $orderProduct['product_price'] ?? 0; $supplierMerId = $orderMerId ?? 0; + // 如果是委托商品入库后就成为供应链商家的采购类型商品 + if ($orderProduct['product_type'] == 99) { + $product->product_type = 98; + } } if ($stockIn <= 0) { throw new ValidateException('入库数量不能小于等于0'); @@ -2374,7 +2380,7 @@ class ProductRepository extends BaseRepository } $find = Db::name('store_product')->where('product_id', $product_id)->find(); if ($find) { - if (!in_array($find['product_type'], [0, 98])) { + if (!in_array($find['product_type'], [0, 98, 99])) { throw new ValidateException('该商品不是普通商品'); } $exist = Db::name('store_product')->where('source_product_id', $product_id)->where('mer_id', $mer_id)->find(); diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index edb7d260..163bf456 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -281,6 +281,7 @@ class SpuRepository extends BaseRepository switch ($productType) { case 0: case 98: + case 99: $where = [ 'activity_id' => 0, 'product_id' => $id, @@ -379,14 +380,14 @@ class SpuRepository extends BaseRepository } $ret = $make->getWhere(['product_id' => $where['product_id']]); if (!$ret || $ret['status'] !== 1 || $ret['mer_status'] !== 1 || $ret['is_del']) $status = 0; - if (in_array($productType, [0, 1,98]) && ($ret['is_show'] !== 1 || $ret['is_used'] !== 1)) $status = 0; + if (in_array($productType, [0, 1, 98, 99]) && ($ret['is_show'] !== 1 || $ret['is_used'] !== 1)) $status = 0; $result = $this->dao->getSearch($where)->find(); if (!$result && $ret) $result = $this->create($ret->toArray(), $where['product_id'], $where['activity_id'], $productType); if ($result) $this->dao->update($result['spu_id'], ['status' => $status]); - if ($status == 1 && in_array($productType, [0, 98])) { + if ($status == 1 && in_array($productType, [0, 98, 99])) { Queue(SendSmsJob::class, ['tempId' => 'PRODUCT_INCREASE', 'id' => $id]); } - if (in_array($productType, [0, 98])) Queue::push(SyncProductTopJob::class,[]); + if (in_array($productType, [0, 98, 99])) Queue::push(SyncProductTopJob::class,[]); return true; } catch (\Exception $exception) { Log::info($exception->getMessage()); @@ -464,6 +465,7 @@ class SpuRepository extends BaseRepository switch ($productType) { case 0: case 98: + case 99: $where = [ 'activity_id' => 0, 'product_id' => $id, diff --git a/app/common/repositories/system/LhappRepository.php b/app/common/repositories/system/LhappRepository.php new file mode 100644 index 00000000..3d23de07 --- /dev/null +++ b/app/common/repositories/system/LhappRepository.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\system; + + +use app\common\dao\system\AppUpdateDao; +use app\common\repositories\BaseRepository; +use think\db\exception\DbException; +use think\exception\ValidateException; +use think\facade\Cache; + +/** + * Class LhappRepository + * @package app\common\repositories\system + * @author xaboy + * @day 2020-04-24 + * @mixin CacheDao + */ +class LhappRepository extends BaseRepository +{ + + + /** + * CacheRepository constructor. + * @param CacheDao $dao + */ + public function __construct(AppUpdateDao $dao) + { + $this->dao = $dao; + } + +} diff --git a/app/common/repositories/system/merchant/MerchantCategoryRepository.php b/app/common/repositories/system/merchant/MerchantCategoryRepository.php index 167eaf42..53a87746 100644 --- a/app/common/repositories/system/merchant/MerchantCategoryRepository.php +++ b/app/common/repositories/system/merchant/MerchantCategoryRepository.php @@ -85,6 +85,7 @@ class MerchantCategoryRepository extends BaseRepository Elm::input('category_name', '分类名称')->required(), Elm::number('commission_rate', '手续费(%)', 0)->required()->max(100)->precision(2), Elm::frameImage('background', '背景图', '/' . config('admin.admin_prefix') . '/setting/uploadPicture?field=background&type=1')->width('896px')->height('480px')->props(['footer' => false])->modal(['modal' => false, 'custom-class' => 'suibian-modal']), + Elm::frameImage('cover', '主图', '/' . config('admin.admin_prefix') . '/setting/uploadPicture?field=cover&type=1')->width('896px')->height('480px')->props(['footer' => false])->modal(['modal' => false, 'custom-class' => 'suibian-modal']), Elm::textarea('description', '简介')->required(), ]); diff --git a/app/common/service/JgPush.php b/app/common/service/JgPush.php index 43cd3840..839d81f6 100644 --- a/app/common/service/JgPush.php +++ b/app/common/service/JgPush.php @@ -64,6 +64,7 @@ class JgPush } break; case 'MERCHANT_CREDIT_BUY_NOTICE': + // 委托商品是否需要提醒信息 $route = "/pages/order_details/stay?order_id={$data['orderId']}&product_type=98"; $merUserId = Merchant::where('mer_id', $data['id'])->value('uid'); $jgRegisterId = User::where('uid', $merUserId)->value('jg_register_id'); diff --git a/app/controller/admin/system/Lhapp.php b/app/controller/admin/system/Lhapp.php new file mode 100644 index 00000000..06fb2fda --- /dev/null +++ b/app/controller/admin/system/Lhapp.php @@ -0,0 +1,34 @@ + +// +---------------------------------------------------------------------- +namespace app\controller\admin\system; + +use app\common\repositories\system\LhappRepository; +use crmeb\basic\BaseController; +use think\App; + +class Lhapp extends BaseController +{ + /** + * @var LhappRepository + */ + protected $repository; + + /** + * CacheRepository constructor. + * @param App $app + */ + public function __construct(App $app, LhappRepository $repository) + { + parent::__construct($app); + $this->repository = $repository; + } + +} diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index 4efab1d6..cb184416 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -102,7 +102,7 @@ class Merchant extends BaseController if (!empty($data['mer_phone'])) { $newUid = Db::name('User')->where('account', $data['mer_phone'])->value('uid', 0); if ($newUid) { - return app('json')->fail('该商家手机号已存在账户,请更换手机'); + //return app('json')->fail('该商家手机号已存在账户,请更换手机'); } } $this->repository->createMerchant($data); @@ -152,7 +152,7 @@ class Merchant extends BaseController $newUid = Db::name('User')->where('account', $data['mer_phone'])->value('uid', -1); $merId = Db::name('Merchant')->where('uid', $newUid)->value('mer_id', 0); if ($newUid != -1 && $id != $merId) { - return app('json')->fail('该商家手机号已存在账户,请更换手机'); + //return app('json')->fail('该商家手机号已存在账户,请更换手机'); } unset($data['mer_account'], $data['mer_password']); $margin = $this->repository->checkMargin($id, $data['type_id']); diff --git a/app/controller/admin/system/merchant/MerchantCategory.php b/app/controller/admin/system/merchant/MerchantCategory.php index 43e974e2..1d22c468 100644 --- a/app/controller/admin/system/merchant/MerchantCategory.php +++ b/app/controller/admin/system/merchant/MerchantCategory.php @@ -154,7 +154,7 @@ class MerchantCategory extends BaseController */ public function checkParams(MerchantCategoryValidate $validate) { - $data = $this->request->params(['category_name', ['commission_rate', 0], 'background', 'description']); + $data = $this->request->params(['category_name', ['commission_rate', 0], 'background', 'cover', 'description']); $validate->check($data); return $data; } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 56d922a5..0f2ba7f4 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -207,13 +207,18 @@ class Auth extends BaseController // 这里有点小问题以后要修改 $store_service = Db::name('store_service')->where('uid', $data['uid'])->find(); if ($store_service) { - $mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name')->find(); + $mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time')->find(); if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') { $data['is_wsxx'] = 1; } $data['mer_info'] = $mer_arr; $typCode = Db::name('merchant_type')->where('mer_type_id', $mer_arr['type_id'] ?? 0)->value('type_code'); $data['mer_info']['type_code'] = $typCode; + if ($mer_arr['create_time'] == $mer_arr['update_time']) { + $data['mer_info']['setup_status'] = 0; + } else { + $data['mer_info']['setup_status'] = 1; + } } $data['fan_num'] = app()->make(RelevanceRepository::class)->getUserFans($user->uid, 1, 1, 1); $data['focus_num'] = app()->make(RelevanceRepository::class)->getUserFocus($user->uid, 1, 1, 1); @@ -1291,6 +1296,7 @@ class Auth extends BaseController } return app('json')->success([]); } + //根据street_id获取商户信息 public function regionMerchant($street_id) { diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index c2c22e88..9d81edd8 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -501,7 +501,7 @@ class Common extends BaseController ->where('m.status',1) ->where('m.street_id',$street_code) ->join('merchant_category c','m.category_id=c.merchant_category_id') - ->field('m.mer_id,category_id,category_name,c.background,c.description')->select(); + ->field('m.mer_id,category_id,category_name,c.background,c.cover,c.description')->select(); return app('json')->success($find??[]); } } diff --git a/app/controller/api/community/Community.php b/app/controller/api/community/Community.php index 9cd53615..4dd0f66a 100644 --- a/app/controller/api/community/Community.php +++ b/app/controller/api/community/Community.php @@ -63,7 +63,7 @@ class Community extends BaseController $where = $this->request->params(['keyword','topic_id','is_hot','category_id','spu_id', 'is_type', 'resale_type']); if (!$where['category_id']) { unset($where['category_id']); - } else if ($where['category_id'] == -1) { + } else if ($where['category_id'] == -1) { $where['is_type'] = $this->repository::COMMUNIT_TYPE_VIDEO; unset($where['category_id']); } @@ -292,7 +292,22 @@ class Community extends BaseController $data['status_time'] = date('Y-m-d H:i:s', time()); } if (!$data['video_link']) throw new ValidateException('请上传视频'); + } elseif ($data['is_type'] == 4) { + if (empty($data['entrust_mer_id']) || empty($data['entrust_day'])) { + throw new ValidateException('供应链商家及委托天数不能为空'); + } + $merchantInfo = Db::name('merchant')->where('uid', $this->request->uid())->find(); + if ($data['entrust_mer_id'] == $merchantInfo['mer_id']) { + throw new ValidateException('委托商家不能选择自己'); + } + if ($merchantInfo['credit_buy'] && ($data['entrust_day'] < $merchantInfo['settle_cycle'])) { + throw new ValidateException('委托天数不能小于结算周期'); + } + if (!$merchantInfo['credit_buy'] && ($data['entrust_day'] < 15 || $data['entrust_day'] > 90)) { + throw new ValidateException('委托天数区间范围[15-90]天'); + } } + $data['content'] = filter_emoji($data['content']); MiniProgramService::create()->msgSecCheck($this->request->userInfo(), $data['content'],3,0); app()->make(CommunityValidate::class)->check($data); @@ -461,6 +476,20 @@ class Community extends BaseController return app('json')->success(['cart_id' => $cartIds]); } + /** + * 委托商品加购 + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function addEntrustCart() + { + $communityId = $this->request->param('community_id'); + $cartIds = $this->repository->addEntrustCart($this->request->uid(), $communityId); + return app('json')->success(['cart_id' => $cartIds]); + } + /** * 转售商品列表 * @return mixed @@ -548,7 +577,10 @@ class Community extends BaseController return app('json')->fail('请设置审核状态'); } if ($status == 1) { - Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]); + $res = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]); + if (!$res) { + return app('json')->fail('审核失败'); + } } if ($status == 2) { Db::startTrans(); @@ -559,7 +591,7 @@ class Community extends BaseController Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update(); } Db::name('resale')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]); - Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'status' => -1, 'mer_status' => 2]); + Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => -1, 'mer_status' => 2]); Db::commit(); } catch (\Exception $e) { Db::rollback(); @@ -637,27 +669,34 @@ class Community extends BaseController */ public function checkEntrust($id) { - $communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->find(); + $communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->where('mer_status', 0)->find(); if (!$communityInfo) { return app('json')->fail('委托商品不存在'); } if ($communityInfo['mer_status'] > 0) { return app('json')->fail('该委托商品已审核'); } - $merchantId = Db::name('merchant')->where('uid', $this->request->uid())->value('mer_id'); - if ($merchantId != $communityInfo['entrust_mer_id']) { - return app('json')->fail('当前商户无审核此委托商品权限'); - } $status = $this->request->param('status'); if (!$status) { return app('json')->fail('请设置审核状态'); } // 同意 if ($status == 1) { - Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]); + $merchantId = Db::name('merchant')->where('uid', $this->request->uid())->value('mer_id'); + if ($merchantId != $communityInfo['entrust_mer_id']) { + return app('json')->fail('当前商户无审核此委托商品权限'); + } + $res = Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1, 'entrust_start_date' =>date('Y-m-d H:i:s')]); + if (!$res) { + return app('json')->fail('审核失败'); + } } // 拒绝 if ($status == 2) { + $merchantId = Db::name('merchant')->where('uid', $this->request->uid())->value('mer_id'); + if ($merchantId != $communityInfo['entrust_mer_id']) { + return app('json')->fail('当前商户无审核此委托商品权限'); + } $refusal = $this->request->param('refusal', ''); Db::startTrans(); try { @@ -667,16 +706,50 @@ class Community extends BaseController Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update(); } Db::name('entrust')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]); - Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'refusal' => $refusal, 'status' => -1, 'mer_status' => 2]); + Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['refusal' => $refusal, 'status' => -1, 'mer_status' => 2]); Db::commit(); } catch (\Exception $e) { Db::rollback(); return app('json')->fail('审核委托商品失败'); } } + // 删除 + if ($status == 3) { + if ($communityInfo['uid'] != $this->request->uid()) { + return app('json')->fail('当前商户无删除此委托商品权限'); + } + Db::startTrans(); + try { + $list = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->where('status', 0)->select(); + foreach($list as $prod) { + Db::name('store_product')->where('product_id', $prod['product_id'])->inc('stock', $prod['number'])->update(); + Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update(); + } + Db::name('entrust')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]); + Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['status' => -2, 'is_del' => 1]); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + return app('json')->fail('删除委托商品失败'); + } + } return app('json')->success('审核操作成功'); } + /** + * 供应链商家列表 + * @return mixed + */ + public function supplychainList() + { + $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id'); + [$page, $limit] = $this->getPage(); + $queryBuilder = Db::name('merchant')->where('type_id', $typeSupplyChainId)->where('is_del', 0)->where('status', 1); + $count = $queryBuilder->count(); + $list = $queryBuilder->setOption('field', [])->field(['mer_id', 'mer_name', 'area_id', 'street_id', 'village_id', 'mer_avatar', 'mer_banner', 'mer_address'])->order('mer_id', 'desc')->page($page, $limit)->fetchSql(false)->select(); + return app('json')->success(compact('count', 'list')); + } + /** * 委托商品列表 * @return mixed @@ -707,20 +780,150 @@ class Community extends BaseController $queryBuilder->where('c.mer_status', 2); } $count = $queryBuilder->count(); - $list = $queryBuilder->setOption('field', [])->field(['c.community_id', 'c.uid', 'c.title', 'c.image', 'c.entrust_mer_id', 'm.credit_buy', 'm.settle_cycle', 'm.interest_rate', 'm.mer_name', 'm.mer_avatar', 'c.mer_status'])->order('c.community_id', 'desc')->page($page, $limit)->fetchSql(false)->select(); + $list = $queryBuilder->setOption('field', [])->field(['c.community_id', 'c.uid', 'c.title', 'c.image', 'c.entrust_mer_id', 'c.mer_status', 'c.entrust_order_id', 'c.entrust_finish', 'c.entrust_start_date'])->order('c.community_id', 'desc')->page($page, $limit)->fetchSql(false)->select(); if ($list) $list = $list->toArray(); foreach($list as $k => $v) { - $list[$k]['mer_name'] = 0; - // type:1发起的委托 2收到的委托 - if ($type == 2) { - $merchantInfo = Db::name('merchant')->where('uid', $v['uid'])->find(); - $list[$k]['credit_buy'] = $merchantInfo['credit_buy'] ?? 0; - $list[$k]['settle_cycle'] = $merchantInfo['settle_cycle'] ?? 0; - $list[$k]['interest_rate'] = $merchantInfo['interest_rate'] ?? 0; - $list[$k]['mer_name'] = $merchantInfo['mer_name'] ?? ''; - $list[$k]['mer_avatar'] = $merchantInfo['mer_avatar'] ?? ''; - } + $list[$k]['entrust_day'] = Db::name('entrust')->where('community_id', $v['community_id'])->value('entrust_day', 0); + $list[$k]['mer_info'] = Db::name('merchant')->where('uid', $v['uid'])->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar', 'credit_buy', 'settle_cycle', 'interest_rate'])->find(); + $list[$k]['entrust_mer_info'] = Db::name('merchant')->where('mer_id', $v['entrust_mer_id'])->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar', 'credit_buy', 'settle_cycle', 'interest_rate'])->find(); } return app('json')->success(compact('count', 'list')); } + + /** + * 委托商品详情 + * @return mixed + */ + public function entrustDetail($id) + { + $communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->field(['community_id', 'title', 'image', 'content', 'uid', 'mer_status', 'entrust_mer_id', 'entrust_start_date', 'entrust_finish', 'entrust_finish_refusal'])->find(); + if (!$communityInfo) { + return app('json')->fail('委托商品不存在'); + } + $uid = $this->request->uid(); + $communityInfo['mer_info'] = Db::name('merchant')->where('uid', $uid)->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar', 'settle_cycle', 'interest_rate'])->find(); + $communityInfo['entrust_mer_info'] = Db::name('merchant')->where('mer_id', $communityInfo['entrust_mer_id'])->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar'])->find(); + if (empty($communityInfo['mer_info']) || empty($communityInfo['entrust_mer_info'])) { + return app('json')->fail('无权限查看委托商品'); + } + $entrustDay = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->value('entrust_day'); + $communityInfo['entrust_day'] = $entrustDay; + $communityInfo['product_list'] = Db::name('entrust')->alias('e')->leftJoin('store_product sp','e.product_id = sp.product_id')->leftJoin('store_product_attr_value spav','spav.unique = e.product_attr_unique')->where('e.community_id', $id)->where('sp.is_del', 0)->setOption('field', [])->field(['e.product_id, e.product_attr_unique, e.number, e.price, e.status, spav.price as old_price, sp.store_name, sp.image'])->select(); + if ($communityInfo['product_list']) $communityInfo['product_list'] = $communityInfo['product_list']->toArray(); + foreach($communityInfo['product_list'] as $k => $v) { + $communityInfo['product_list'][$k]['image'] = explode(',', $v['image']);; + } + return app('json')->success($communityInfo); + } + + /** + * 编辑委托商品 + * @return mixed + */ + public function editEntrust($id) + { + $communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->where('mer_status', 0)->find(); + if (!$communityInfo) { + return app('json')->fail('委托商品不存在'); + } + if ($communityInfo['mer_status'] > 0) { + return app('json')->fail('该委托商品已审核'); + } + if ($communityInfo['uid'] != $this->request->uid()) { + return app('json')->fail('当前商户无编辑此委托商品权限'); + } + $this->checkUserAuth(); + Db::startTrans(); + try { + $list = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->where('status', 0)->select(); + foreach($list as $prod) { + Db::name('store_product')->where('product_id', $prod['product_id'])->inc('stock', $prod['number'])->update(); + Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update(); + } + Db::name('entrust')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]); + Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['status' => -2, 'is_del' => 1]); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + return app('json')->fail('编辑委托商品失败'); + } + $data = $this->checkParams(); + $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id'); + $merchantInfo = Db::name('merchant')->where('mer_id', $data['entrust_mer_id'] ?? 0)->where('type_id', $typeSupplyChainId)->fetchSql(false)->find(); + if (!$merchantInfo) { + return app('json')->fail('此商户不支持委托'); + } + $data['uid'] = $this->request->uid(); + $res = $this->repository->create($data); + return app('json')->success(['community_id' => $res]); + } + + /** + * 供应链商家申请结束商品委托 + * @return mixed + */ + public function applyFinishEntrust($id) + { + $communityInfo = Db::name('community')->where('community_id', $id)->where('mer_status', 1)->whereIn('entrust_finish', [0, 2])->where('is_del', 0)->find(); + if (!$communityInfo) { + return app('json')->fail('当前状态委托商品不存在'); + } + $merchantId = Db::name('merchant')->where('uid', $this->request->uid())->value('mer_id'); + if ($merchantId != $communityInfo['entrust_mer_id']) { + return app('json')->fail('当前商户无申请结束此委托商品权限'); + } + $entrustInfo = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->find(); + //委托周期截止5天内可申请结束委托 + $limitTime = strtotime($communityInfo['entrust_start_date']) + ($entrustInfo['entrust_day'] ?? 0) * 86400 - 5 * 86400; + if (time() < $limitTime) { + //return app('json')->fail('委托周期截止5天内可申请结束委托'); + } + $res = Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['entrust_finish' => 3]); + if (!$res) { + return app('json')->fail('申请操作失败'); + } + return app('json')->success('申请操作成功'); + } + + /** + * 结束商品委托 + * @return mixed + */ + public function finishEntrust($id) + { + $communityInfo = Db::name('community')->where('community_id', $id)->where('mer_status', 1)->where('entrust_finish', 3)->where('is_del', 0)->find(); + if (!$communityInfo) { + return app('json')->fail('当前状态委托商品不存在'); + } + if ($this->request->uid() != $communityInfo['uid']) { + return app('json')->fail('当前商户无结束此委托商品权限'); + } + $status = $this->request->param('status'); + if (!$status) { + return app('json')->fail('请设置状态'); + } + // 同意 + if ($status == 1) { + $entrustInfo = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->find(); + //委托周期截止5天内可申请结束委托 + $limitTime = strtotime($communityInfo['entrust_start_date']) + ($entrustInfo['entrust_day'] ?? 0) * 86400 - 5 * 86400; + if (time() < $limitTime) { + //return app('json')->fail('委托周期截止5天内可申请结束委托'); + } + // 分润 + $res = Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['entrust_finish' => 1]); + if (!$res) { + return app('json')->fail('结束操作失败'); + } + } + // 拒绝 + if ($status == 2) { + $refusal = $this->request->param('refusal', ''); + $res = Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['entrust_finish_refusal' => $refusal, 'entrust_finish' => 2]); + if (!$res) { + return app('json')->fail('结束操作失败'); + } + } + return app('json')->success('结束操作成功'); + } } diff --git a/app/controller/api/server/StoreProduct.php b/app/controller/api/server/StoreProduct.php index 9573c9ca..2a9bdfb5 100644 --- a/app/controller/api/server/StoreProduct.php +++ b/app/controller/api/server/StoreProduct.php @@ -60,7 +60,9 @@ class StoreProduct extends BaseController [$page, $limit] = $this->getPage(); $where = $this->request->params(['cate_id', 'keyword', ['type',20], 'mer_cate_id', 'is_gift_bag', 'status', 'us_status', 'product_id', 'mer_labels',['order','sort']]); $merchant = app()->make(MerchantRepository::class)->get($merId); - if ($merchant['type_id']==12){ + $typeCode=Db::name('merchant_type')->where('mer_type_id',$merchant['type_id'])->value('type_code'); + // if ($merchant['type_id']==12){ + if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $product_type=98;//供应链 }else{ $product_type=0;//普通商品 @@ -87,7 +89,9 @@ class StoreProduct extends BaseController $data['status'] = $merchant->is_audit ? 0 : 1; $data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1; $data['rate'] = 3; - if ($merchant['type_id']==12){ + $typeCode=Db::name('merchant_type')->where('mer_type_id',$merchant['type_id'])->value('type_code'); + // if ($merchant['type_id']==12){ + if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $product_type=98;//供应链 }else{ $product_type=0;//普通商品 diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index b17cbaa1..3a8383ad 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -47,11 +47,11 @@ class MerchantIntention extends BaseController if ($this->userInfo) $data['uid'] = $this->userInfo->uid; $newUid = Db::name('User')->where('account', $data['phone'])->value('uid', -1); if ($newUid != -1 && $this->userInfo->uid != $newUid) { - throw new ValidateException('该申请手机已存在账户,不可申请'); + //throw new ValidateException('该申请手机已存在账户,不可申请'); } $newMerid = Db::name('Merchant')->where('mer_phone', $data['phone'])->value('mer_id', -1); if ($newMerid != -1) { - throw new ValidateException('该申请手机已存在商户,不可申请'); + //throw new ValidateException('该申请手机已存在商户,不可申请'); } $make = app()->make(MerchantRepository::class); if ($make->fieldExists('mer_name', $data['mer_name'])) diff --git a/app/controller/api/store/order/StoreCart.php b/app/controller/api/store/order/StoreCart.php index 4b9fe031..4613787a 100644 --- a/app/controller/api/store/order/StoreCart.php +++ b/app/controller/api/store/order/StoreCart.php @@ -82,7 +82,7 @@ class StoreCart extends BaseController } } $entryMerId = $decryptArray[0] ?? ''; - if(!in_array($data['product_type'],[0,1,2,3,4,98])) return app('json')->fail('商品类型错误'); + if(!in_array($data['product_type'],[0,1,2,3,4,98,99])) return app('json')->fail('商品类型错误'); if ($data['cart_num'] <= 0) return app('json')->fail('购买数量有误'); $user = $this->request->userInfo(); event('user.cart.before',compact('user','data')); @@ -90,6 +90,7 @@ class StoreCart extends BaseController { case 0: //普通商品 case 98: //供应链商品 + case 99: //委托商品 $result = app()->make(ProductRepository::class)->cartCheck($data,$this->request->userInfo()); [$source, $sourceId, $pid] = explode(':', $this->request->param('source', '0'), 3) + ['', '', '']; $data['source'] = (in_array($source, [0, 1]) && $pid == $data['product_id']) ? $source : 0; diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 33590406..d5114008 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -97,6 +97,7 @@ class StoreOrder extends BaseController } $uid = $this->request->uid(); + // halt(count($cartId), count($cartRepository->validIntersection($cartId, $uid))); if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid))) return app('json')->fail('数据无效'); diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index b0836968..4e4369d0 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -52,7 +52,10 @@ class Product extends BaseController $where = $this->request->params(['temp_id','cate_id','keyword',['type',1],'mer_cate_id','is_gift_bag','status','us_status','product_id','mer_labels',['order','sort'],'is_ficti','svip_price_type']); $where = array_merge($where,$this->repository->switchType($where['type'],$this->request->merId(),0)); $type=$this->request->merchant()['type_id']; - if ($type==12){ + $typeCode=Db::name('merchant_type')->where('mer_type_id',$type)->value('type_code'); + $product_type=0; + // if ($type==12){ + if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $where['product_type']=98;//供应链 } return app('json')->success($this->repository->getList($this->request->merId(),$where, $page, $limit)); @@ -87,7 +90,9 @@ class Product extends BaseController $data['status'] = $this->request->merchant()->is_audit ? 0 : 1; $data['mer_status'] = ($this->request->merchant()->is_del || !$this->request->merchant()->mer_state || !$this->request->merchant()->status) ? 0 : 1; $data['rate'] = 3; - if ($this->request->merchant()->type_id==12){ + $typeCode=Db::name('merchant_type')->where('mer_type_id',$this->request->merchant()->type_id)->value('type_code'); + // if ($this->request->merchant()->type_id==12){ + if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $product_type=98;//供应链 }else{ $product_type=0;//普通商品 @@ -164,7 +169,9 @@ class Product extends BaseController { $type=$this->request->merchant()['type_id']; $product_type=0; - if ($type==12){ + $typeCode=Db::name('merchant_type')->where('mer_type_id',$type)->value('type_code'); + // if ($type==12){ + if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ $product_type=98;//供应链 } return app('json')->success($this->repository->getFilter($this->request->merId(),'商品',$product_type)); diff --git a/app/listener/OrderCreate.php b/app/listener/OrderCreate.php index 11eff96c..6377f29b 100644 --- a/app/listener/OrderCreate.php +++ b/app/listener/OrderCreate.php @@ -18,7 +18,7 @@ class OrderCreate { $groupOrder = $event['groupOrder']; $order = $groupOrder->orderList[0]; - if ($order['pay_type'] != StoreGroupOrder::PAY_TYPE_CREDIT_BUY || $order['activity_type'] != 98) { + if ($order['pay_type'] != StoreGroupOrder::PAY_TYPE_CREDIT_BUY || !in_array($order['activity_type'], [98, 99])) { return true; } /** @var StoreOrderInterestRepository $storeOrderInterestRepository */ diff --git a/app/listener/SendGoodsCode.php b/app/listener/SendGoodsCode.php index 819d1d71..babf6cbe 100644 --- a/app/listener/SendGoodsCode.php +++ b/app/listener/SendGoodsCode.php @@ -74,8 +74,9 @@ class SendGoodsCode //发送物流 public function sendLogistics($orderId, $orderSn) { - Log::info("发送物流信息 orderId: {$orderId}, orderSn: {$orderSn}"); $postUrl = env('LOGISTICS_HOST_URL') . '/api/lstSet'; + Log::info("物流HOST: {$postUrl}"); + Log::info("发送物流信息 orderId: {$orderId}, orderSn: {$orderSn}"); $curlPost = [ 'order_id' => $orderId, 'order_sn' => $orderSn, diff --git a/app/validate/api/CommunityValidate.php b/app/validate/api/CommunityValidate.php index fd6974f1..2879c057 100644 --- a/app/validate/api/CommunityValidate.php +++ b/app/validate/api/CommunityValidate.php @@ -20,7 +20,7 @@ class CommunityValidate extends Validate protected $failException = true; protected $rule = [ - 'image|图片' => 'require|array', + 'image|图片' => 'array', 'content|内容' => 'require|max:600', 'spu_id|关联商品' => 'array', ]; diff --git a/crmeb/jobs/SendGoodsCodeJob.php b/crmeb/jobs/SendGoodsCodeJob.php index 749f33b1..1f7686fc 100644 --- a/crmeb/jobs/SendGoodsCodeJob.php +++ b/crmeb/jobs/SendGoodsCodeJob.php @@ -68,7 +68,6 @@ class SendGoodsCodeJob implements JobInterface //商品信息 $productInfo = Db::name('store_order_product')->where('order_id', $order['order_id'] ?? 0)->find(); if ($productInfo) { - } //商户信息 $merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find(); diff --git a/public/index.dev.html b/public/index.dev.html index 7087543f..2c6cfb2f 100644 --- a/public/index.dev.html +++ b/public/index.dev.html @@ -2,4 +2,4 @@ document.write('') if(window.location.protocol == 'https:'){ document.write('') - }