diff --git a/404.html b/404.html new file mode 100644 index 00000000..6f17eaf5 --- /dev/null +++ b/404.html @@ -0,0 +1,7 @@ + +404 Not Found + +

404 Not Found

+
nginx
+ + \ No newline at end of file diff --git a/app/common/model/store/StoreCategory.php b/app/common/model/store/StoreCategory.php index 1b565c50..5e325c2a 100644 --- a/app/common/model/store/StoreCategory.php +++ b/app/common/model/store/StoreCategory.php @@ -19,6 +19,9 @@ use think\Model; class StoreCategory extends BaseModel { + // 设置当前模型的数据库连接 + protected $connection = 'mysql'; + /** * @return string * @author xaboy diff --git a/app/common/model/store/product/Spu.php b/app/common/model/store/product/Spu.php index 16c03d90..f2df5a5f 100644 --- a/app/common/model/store/product/Spu.php +++ b/app/common/model/store/product/Spu.php @@ -17,6 +17,7 @@ use app\common\model\BaseModel; use app\common\model\store\coupon\StoreCouponProduct; use app\common\model\store\StoreSeckillActive; use app\common\model\system\merchant\Merchant; +use app\common\model\system\supplychain\SupplyChainLinkMerchant; use think\db\BaseQuery; class Spu extends BaseModel @@ -163,6 +164,16 @@ class Spu extends BaseModel { return $this->hasOne(Merchant::class,'mer_id','mer_id'); } + + /** + * 供应链中间件 + * + */ + public function supplyChainLink() + { + return $this->hasOne(SupplyChainLinkMerchant::class, 'mer_id', 'eb_merchant_id'); + } + public function issetCoupon() { return $this->hasOne(StoreCouponProduct::class, 'product_id', 'product_id')->alias('A') diff --git a/app/common/model/system/merchant/Merchant.php b/app/common/model/system/merchant/Merchant.php index 688a4a45..f9314245 100644 --- a/app/common/model/system/merchant/Merchant.php +++ b/app/common/model/system/merchant/Merchant.php @@ -24,6 +24,8 @@ use app\common\model\system\config\SystemConfigValue; use app\common\model\system\financial\Financial; use app\common\model\system\serve\ServeOrder; use app\common\repositories\store\StoreActivityRepository; +use app\common\model\system\supplychain\SupplyChain; +use app\common\model\system\supplychain\SupplyChainLinkMerchant; class Merchant extends BaseModel { @@ -53,7 +55,7 @@ class Merchant extends BaseModel if (!$value) return []; return explode(',',$value); } - + public function product() { return $this->hasMany(Product::class, 'mer_id', 'mer_id'); @@ -64,6 +66,7 @@ class Merchant extends BaseModel return $this->hasMany(SystemConfigValue::class, 'mer_id', 'mer_id'); } + public function showProduct() { return $this->hasMany(Product::class, 'mer_id', 'mer_id') @@ -181,6 +184,25 @@ class Merchant extends BaseModel return $this->merchantType()->bind(['type_name']); } + /** + * 供应链中间件 + * + */ + public function SupplyChainLink() + { + return $this->hasOne(SupplyChainLinkMerchant::class, 'eb_merchant_id', 'mer_id'); + } + + /** + * + * 关联供应链 + * + */ + public function supplyChain() + { + return $this->hasOneThrough(SupplyChain::class, SupplyChainLinkMerchant::class, 'eb_merchant_id', 'id', 'mer_id', 'fa_supply_chain_id'); + } + public function getMerCommissionRateAttr() { return $this->commission_rate > 0 ? $this->commission_rate : bcmul($this->merchantCategory->commission_rate, 100, 4); diff --git a/app/common/model/system/supplychain/SupplyChain.php b/app/common/model/system/supplychain/SupplyChain.php new file mode 100644 index 00000000..70139318 --- /dev/null +++ b/app/common/model/system/supplychain/SupplyChain.php @@ -0,0 +1,45 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\system\supplychain; + + +use app\common\model\BaseModel; + +class SupplyChain extends BaseModel +{ + + // 设置当前模型的数据库连接 + protected $connection = 'nongke'; + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tablePk(): string + { + return 'id'; + } + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tableName(): string + { + return 'fa_supply_chain'; + } + +} diff --git a/app/common/model/system/supplychain/SupplyChainLinkMerchant.php b/app/common/model/system/supplychain/SupplyChainLinkMerchant.php new file mode 100644 index 00000000..1461e960 --- /dev/null +++ b/app/common/model/system/supplychain/SupplyChainLinkMerchant.php @@ -0,0 +1,65 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\system\supplychain; + + +use app\common\model\BaseModel; +use app\common\model\store\StoreCategory; + +class SupplyChainLinkMerchant extends BaseModel +{ + + // 设置当前模型的数据库连接 + protected $connection = 'nongke'; + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tablePk(): string + { + return 'id'; + } + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tableName(): string + { + return 'fa_supply_chain_link_merchant'; + } + + /** + * 所属供应链 + * 一对一 + * + */ + public function supplyChain() + { + return $this->hasOne(SupplyChain::class, 'id', 'fa_supply_chain_id'); + } + + /** + * + * 商户下的分类 + * + */ + public function category() + { + return $this->hasMany(StoreCategory::class, 'mer_id', 'eb_merchant_id'); + } +} diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 1ea7ac87..9b59018f 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -895,8 +895,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository ) + ['allow_address' => !$allow_no_address, 'order_delivery_status' => $orderDeliveryStatus]; } - public function v2CreateOrder(int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post) + public function v2CreateOrder(int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post, int $source) { + $uid = $user->uid; $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true); $order_model = $orderInfo['order_model']; diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index e4935d9d..1b9877e5 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -25,6 +25,7 @@ use app\common\dao\store\product\SpuDao; use app\common\repositories\store\StoreCategoryRepository; use app\common\repositories\store\StoreSeckillActiveRepository; use app\common\repositories\user\UserVisitRepository; +use app\common\model\system\supplychain\SupplyChainLinkMerchant; use think\facade\Queue; class SpuRepository extends BaseRepository @@ -118,11 +119,12 @@ class SpuRepository extends BaseRepository * @param $page * @param $limit * @param $userInfo + * @param $source 请求来源 * @return array * @author Qinii * @day 12/18/20 */ - public function getApiSearch($where, $page, $limit, $userInfo = null) + public function getApiSearch($where, $page, $limit, $userInfo = null, $source = 2) { if (isset($where['keyword']) && !empty($where['keyword'])) { if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) { @@ -137,14 +139,29 @@ class SpuRepository extends BaseRepository } $where['spu_status'] = 1; $where['mer_status'] = 1; + $query = $this->dao->search($where); $query->with([ 'merchant' => function ($query) { $query->field($this->merchantFiled)->with(['type_name']); }, - 'issetCoupon', + 'issetCoupon' ]); + + // 假如是小组服务采购商品,则增加供应链商品的筛选,只获取已入驻商户的商品 + if($source == 1) + { + // 获取供应链商户ID + $MerListId = SupplyChainLinkMerchant::with(['supplyChain', 'category']) + ->hasWhere('supplyChain', ['status' => 1]) // 启用的供应链团队 + ->group('eb_merchant_id') // 以分类分组 + ->column('eb_merchant_id'); + + // 只获取当前供应链内商户的商品 + $query->whereIn('S.mer_id', $MerListId); + } + $productMake = app()->make(ProductRepository::class); $count = $query->count(); @@ -154,6 +171,7 @@ class SpuRepository extends BaseRepository $append[] = 'max_extension'; $list->append($append); $list = $this->getBorderList($list); + return compact('count', 'list'); } diff --git a/app/controller/api/store/order/StoreCart.php b/app/controller/api/store/order/StoreCart.php index a956b9ca..6a2323cf 100644 --- a/app/controller/api/store/order/StoreCart.php +++ b/app/controller/api/store/order/StoreCart.php @@ -68,7 +68,7 @@ class StoreCart extends BaseController { $data = $this->checkParams($validate); - if(!in_array($data['product_type'],[0,1,2,3,4])) return app('json')->fail('商品类型错误'); + if(!in_array($data['product_type'],[0,1,2,3,4,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')); @@ -103,7 +103,7 @@ class StoreCart extends BaseController $data['product_id'] = $result['product']['product_id']; break; case 99: //小组代购 - $result = app()->make(ProductGroupRepository::class)->cartCheck($data,$this->request->userInfo()); + $result = app()->make(ProductRepository::class)->cartCheck($data,$this->request->userInfo()); $data['source'] = $data['product_type']; $data['source_id'] = $data['group_buying_id']; $data['product_id'] = $result['product']['product_id']; diff --git a/app/controller/api/store/order/StoreCartDg.php b/app/controller/api/store/order/StoreCartDg.php index 4b924a3f..32c55232 100644 --- a/app/controller/api/store/order/StoreCartDg.php +++ b/app/controller/api/store/order/StoreCartDg.php @@ -106,7 +106,7 @@ class StoreCartDg extends BaseController $data['product_id'] = $result['product']['product_id']; break; case 99: //小组代购 - $result = app()->make(ProductGroupRepository::class)->cartCheck($data,$this->request->userInfo()); + $result = app()->make(ProductDgRepository::class)->cartCheck($data,$this->request->userInfo()); $data['source'] = $data['product_type']; $data['source_id'] = $data['group_buying_id']; $data['product_id'] = $result['product']['product_id']; diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index a0bda7be..57a687aa 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -88,6 +88,7 @@ class StoreOrder extends BaseController $payType = $this->request->param('pay_type'); $post = (array)$this->request->param('post'); $is_dg = $this->request->param('is_dg',0); + $source = (int)$this->request->param('source'); // 1 小组服务 2 普通来源 $isPc = $payType === 'pc'; if ($isPc) { $payType = 'balance'; @@ -115,8 +116,8 @@ class StoreOrder extends BaseController // if (!$addressId) // return app('json')->fail('请选择地址'); - $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); + $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post,$source) { + return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post,$source); }); if ($groupOrder['pay_price'] == 0) { diff --git a/app/controller/api/store/product/StoreCategory.php b/app/controller/api/store/product/StoreCategory.php index ff461403..931f6e7f 100644 --- a/app/controller/api/store/product/StoreCategory.php +++ b/app/controller/api/store/product/StoreCategory.php @@ -38,8 +38,11 @@ class StoreCategory extends BaseController */ public function lst() { + $source = $this->request->param('source'); // 1 小组服务 2 普通来源 + $data = $this->repository->getHot(0); - $list = $this->repository->getApiFormatList(0,1); + $list = $this->repository->getApiFormatList(0, 1, $source); + $ret =[]; foreach ($list as $key => $value) { if (isset($value['children'])) { diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 13529971..22bc1a6c 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -60,11 +60,13 @@ class StoreSpu extends BaseController 'merchant_category_id', 'is_good' ]); + $where['is_gift_bag'] = 0; $where['product_type'] = 0; $where['order'] = $where['order'] ?: 'star'; + $source = $this->request->param('source'); // 1 小组服务 2 普通来源 if ($where['is_trader'] != 1) unset($where['is_trader']); - $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); + $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo, $source); return app('json')->success($data); } diff --git a/basic/BaseAuth.php b/basic/BaseAuth.php new file mode 100644 index 00000000..f67c68d6 Binary files /dev/null and b/basic/BaseAuth.php differ diff --git a/basic/BaseController.php b/basic/BaseController.php new file mode 100644 index 00000000..3c71dd1a Binary files /dev/null and b/basic/BaseController.php differ diff --git a/basic/BaseManager.php b/basic/BaseManager.php new file mode 100644 index 00000000..cbd1b23f Binary files /dev/null and b/basic/BaseManager.php differ diff --git a/basic/BaseMessage.php b/basic/BaseMessage.php new file mode 100644 index 00000000..152f7265 Binary files /dev/null and b/basic/BaseMessage.php differ diff --git a/basic/BaseStorage.php b/basic/BaseStorage.php new file mode 100644 index 00000000..1beb82b2 Binary files /dev/null and b/basic/BaseStorage.php differ diff --git a/basic/BaseUpload.php b/basic/BaseUpload.php new file mode 100644 index 00000000..9bf89f71 Binary files /dev/null and b/basic/BaseUpload.php differ diff --git a/crmeb/traits/CategoresDao.php b/crmeb/traits/CategoresDao.php index b456c8dd..b9e972df 100644 --- a/crmeb/traits/CategoresDao.php +++ b/crmeb/traits/CategoresDao.php @@ -12,6 +12,9 @@ namespace crmeb\traits; +use app\common\model\system\supplychain\SupplyChainLinkMerchant; + + trait CategoresDao { public $path = 'path'; @@ -79,11 +82,29 @@ trait CategoresDao * @return mixed * @author Qinii */ - public function getAll($mer_id = 0,$status = null) - { - return $this->getModel()::getDB()->where('mer_id', $mer_id)->when(($status !== null),function($query)use($status){ + public function getAll($mer_id = 0,$status = null, $source = 2) + { + // 验证来源 1 小组服务 2 普通来源 + if($source == 1) + { + // 获取供应链商户ID + $MerList = SupplyChainLinkMerchant::with(['supplyChain', 'category']) + ->hasWhere('supplyChain', ['status' => 1]) // 启用的供应链团队 + ->group('eb_merchant_id') // 以分类分组 + ->column('eb_merchant_id'); + + // 获取供应链商户共同拥有的分类 + return $this->getModel()::getDB()->whereIn('mer_id', $MerList)->when(($status !== null),function($query)use($status){ $query->where($this->getStatus(),$status); })->order('sort DESC,'.$this->getPk().' DESC')->select(); + + }else{ + \think\facade\Log::record('普通访问'); + return $this->getModel()::getDB()->where('mer_id', $mer_id)->when(($status !== null),function($query)use($status){ + $query->where($this->getStatus(),$status); + })->order('sort DESC,'.$this->getPk().' DESC')->select(); + } + } /** diff --git a/crmeb/traits/CategoresRepository.php b/crmeb/traits/CategoresRepository.php index 8631f0b4..60c85d1e 100644 --- a/crmeb/traits/CategoresRepository.php +++ b/crmeb/traits/CategoresRepository.php @@ -33,8 +33,8 @@ trait CategoresRepository * @param null $status * @return array */ - public function getApiFormatList($merID,$status = null) - { + public function getApiFormatList($merID,$status = null, $source = 2) + { return formatCategory($this->dao->getAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk()); } diff --git a/index.html b/index.html new file mode 100644 index 00000000..86aeca22 --- /dev/null +++ b/index.html @@ -0,0 +1,39 @@ + + + + + 恭喜,站点创建成功! + + + +
+

恭喜, 站点创建成功!

+

这是默认index.html,本页面由系统自动生成

+ +
+ + \ No newline at end of file diff --git a/public/nginx.htaccess b/public/nginx.htaccess new file mode 100644 index 00000000..e69de29b