From 30426a5319764f7666db8b07381ab9060fcce214 Mon Sep 17 00:00:00 2001
From: wuhui_zzw <1760308791@qq.com>
Date: Wed, 10 Apr 2024 14:58:51 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E4=BB=A3=E5=AE=A2?=
=?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugins/help-user-buying/README.md | 1 +
plugins/help-user-buying/callbacks.php | 17 +
plugins/help-user-buying/package.json | 11 +
.../src/Listener/SeparatedTestListener.php | 20 +
.../src/PluginApplication.php | 240 +++++
.../src/admin/HomeController.php | 209 +++++
.../src/admin/IndexController.php | 437 +++++++++
.../src/admin/MemberAddressController.php | 230 +++++
.../src/admin/UserMergePayController.php | 173 ++++
.../src/common/CategoryFactory.php | 65 ++
.../help-user-buying/src/common/MenuHook.php | 413 +++++++++
.../src/common/OrderObserver.php | 49 +
.../payment/types/HelpOrderPaymentTypes.php | 10 +
plugins/help-user-buying/src/models/Goods.php | 27 +
.../src/models/GoodsOption.php | 18 +
.../src/shop/controller/CreateController.php | 26 +
.../shop/controller/GoodsBuyController.php | 51 ++
.../src/store/controller/CreateController.php | 16 +
.../store/controller/GoodsBuyController.php | 41 +
.../store/controller/OperationController.php | 62 ++
.../src/store/models/Category.php | 50 ++
.../src/store/models/Store.php | 12 +
.../src/store/models/StoreGoods.php | 59 ++
.../src/supplier/models/SupplierGoods.php | 64 ++
.../views/admin/index.blade.php | 682 ++++++++++++++
.../views/admin/payform.blade.php | 98 ++
.../views/admin/select.blade.php | 158 ++++
.../views/buying/goods.blade.php | 613 +++++++++++++
.../views/buying/order.blade.php | 848 ++++++++++++++++++
.../views/buying/select.blade.php | 163 ++++
.../template/editMemberAddress.blade.php | 356 ++++++++
31 files changed, 5219 insertions(+)
create mode 100644 plugins/help-user-buying/README.md
create mode 100644 plugins/help-user-buying/callbacks.php
create mode 100644 plugins/help-user-buying/package.json
create mode 100644 plugins/help-user-buying/src/Listener/SeparatedTestListener.php
create mode 100644 plugins/help-user-buying/src/PluginApplication.php
create mode 100644 plugins/help-user-buying/src/admin/HomeController.php
create mode 100644 plugins/help-user-buying/src/admin/IndexController.php
create mode 100644 plugins/help-user-buying/src/admin/MemberAddressController.php
create mode 100644 plugins/help-user-buying/src/admin/UserMergePayController.php
create mode 100644 plugins/help-user-buying/src/common/CategoryFactory.php
create mode 100644 plugins/help-user-buying/src/common/MenuHook.php
create mode 100644 plugins/help-user-buying/src/common/OrderObserver.php
create mode 100644 plugins/help-user-buying/src/common/payment/types/HelpOrderPaymentTypes.php
create mode 100644 plugins/help-user-buying/src/models/Goods.php
create mode 100644 plugins/help-user-buying/src/models/GoodsOption.php
create mode 100644 plugins/help-user-buying/src/shop/controller/CreateController.php
create mode 100644 plugins/help-user-buying/src/shop/controller/GoodsBuyController.php
create mode 100644 plugins/help-user-buying/src/store/controller/CreateController.php
create mode 100644 plugins/help-user-buying/src/store/controller/GoodsBuyController.php
create mode 100644 plugins/help-user-buying/src/store/controller/OperationController.php
create mode 100644 plugins/help-user-buying/src/store/models/Category.php
create mode 100644 plugins/help-user-buying/src/store/models/Store.php
create mode 100644 plugins/help-user-buying/src/store/models/StoreGoods.php
create mode 100644 plugins/help-user-buying/src/supplier/models/SupplierGoods.php
create mode 100644 plugins/help-user-buying/views/admin/index.blade.php
create mode 100644 plugins/help-user-buying/views/admin/payform.blade.php
create mode 100644 plugins/help-user-buying/views/admin/select.blade.php
create mode 100644 plugins/help-user-buying/views/buying/goods.blade.php
create mode 100644 plugins/help-user-buying/views/buying/order.blade.php
create mode 100644 plugins/help-user-buying/views/buying/select.blade.php
create mode 100644 plugins/help-user-buying/views/buying/template/editMemberAddress.blade.php
diff --git a/plugins/help-user-buying/README.md b/plugins/help-user-buying/README.md
new file mode 100644
index 00000000..cd03384b
--- /dev/null
+++ b/plugins/help-user-buying/README.md
@@ -0,0 +1 @@
+## Yunshop 插件开发简易文档
diff --git a/plugins/help-user-buying/callbacks.php b/plugins/help-user-buying/callbacks.php
new file mode 100644
index 00000000..dfe78a47
--- /dev/null
+++ b/plugins/help-user-buying/callbacks.php
@@ -0,0 +1,17 @@
+ function (app\common\services\PluginManager $manager, $plugins) {
+ // 你也可以在回调函数的参数列表中使用类型提示,Laravel 服务容器将会自动进行依赖注入
+ \Artisan::call('migrate', ['--path' => 'plugins/help-user-buying/migrations', '--force' => true]);
+ Log::info('[ExamplePlugin] 示例插件已启用,IoC 容器自动为我注入了 PluginManager 实例:', compact('manager'));
+ },
+ app\common\events\PluginWasDisabled::class => function ($plugin) {
+ // 回调函数被调用时 Plugin 实例会被传入作为参数
+ Log::info('[help-user-buying] 示例插件已禁用,我拿到了插件实例', ['instance' => $plugin]);
+ },
+ app\common\events\PluginWasDeleted::class => function () {
+ \Artisan::call('migrate:rollback', ['--path' => 'plugins/help-user-buying/migrations']);
+ Log::info('[help-user-buying] 啊啊啊啊啊啊啊我被删除啦 QwQ');
+ }
+];
diff --git a/plugins/help-user-buying/package.json b/plugins/help-user-buying/package.json
new file mode 100644
index 00000000..c80a0a7f
--- /dev/null
+++ b/plugins/help-user-buying/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "help-user-buying",
+ "terminal": "",
+ "version": "2.0.26",
+ "title": "代客下单",
+ "description": "代替客户在后台下单,支持自营,门店,供应商。",
+ "author": "blank",
+ "url": "https://www.yunzshop.com/",
+ "namespace": "Yunshop\\HelpUserBuying",
+ "config": "config.tpl"
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/Listener/SeparatedTestListener.php b/plugins/help-user-buying/src/Listener/SeparatedTestListener.php
new file mode 100644
index 00000000..fa760c22
--- /dev/null
+++ b/plugins/help-user-buying/src/Listener/SeparatedTestListener.php
@@ -0,0 +1,20 @@
+setPluginMenu('help_user_buying', [
+ 'name' => '代客下单',
+ 'type' => 'industry',
+ 'url' => 'plugin.help-user-buying.admin.index.index', //url 可以填写http 也可以直接写路由
+ 'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
+ 'permit' => 1,//如果不设置则不会做权限检测
+ 'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
+ 'top_show' => 0,
+ 'left_first_show' => 0,
+ 'left_second_show' => 0,
+ 'icon' => '',//菜单图标
+ 'list_icon' => 'help_user_buying',
+ 'parents' => [],
+ 'child' => [
+// 'help-user-buying-select' => [
+// 'name' => '选择基地',
+// 'permit' => 1,
+// 'menu' => 1,
+// 'icon' => '',
+// 'url' => 'plugin.help-user-buying.admin.home.select',
+// 'url_params'=> '',
+// 'parents' => ['help_user_buying'],
+// 'child' => []
+// ],
+ 'help-user-buying-index' => [
+ 'name' => '选择订单类型',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-order' => [
+ 'name' => '下单页',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.set-member-id',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-shop-index' => [
+ 'name' => '商城商品下单',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.shop-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-shop-goods-list' => [
+ 'name' => '商城商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.shopGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ 'help-user-buying-shop-goods-buy' => [
+ 'name' => '商城订单预下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ 'help-user-buying-shop-create' => [
+ 'name' => '商城订单下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-store-index' => [
+ 'name' => '门店商品下单',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.store-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-store-goods-list' => [
+ 'name' => '门店商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.storeGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-store-goods-buy' => [
+ 'name' => '门店订单预下单',
+ 'url' => 'plugin.help-user-buying.store.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-store-create' => [
+ 'name' => '门店订单下单',
+ 'url' => 'plugin.help-user-buying.store.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-supplier-index' => [
+ 'name' => '供应商商品下单',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.supplier-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-supplier-goods-list' => [
+ 'name' => '供应商商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.supplierGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-supplier-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-goods-increase' => [
+ 'name' => '商品加减',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.goods-increase',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-get-search-member' => [
+ 'name' => '获取搜索会员',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.getSearchMember',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-user-merge-pay' => [
+ 'name' => '支付',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-user-merge-pay-credit2' => [
+ 'name' => '余额支付',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.credit2',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ 'help-user-buying-user-merge-pay-COD' => [
+ 'name' => '货到付款',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.COD',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ 'help-user-buying-user-merge-pay-confirmPay' => [
+ 'name' => '确认支付',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.confirmPay',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ ]
+ ],
+ 'help-user-buying-address' => [
+ 'name' => '获取地址数据',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.member-address.get-address',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-editMemberAddress' => [
+ 'name' => '编辑收货地址',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'url' => 'plugin.help-user-buying.admin.member-address.edit-member-address',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-createMemberAddress' => [
+ 'name' => '新增收货地址',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'url' => 'plugin.help-user-buying.admin.member-address.create-member-address',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-search-source' => [
+ 'name' => '搜索',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.get-source',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ]
+ ]
+ ]);
+
+ }
+
+ public function boot()
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/admin/HomeController.php b/plugins/help-user-buying/src/admin/HomeController.php
new file mode 100644
index 00000000..bdf97e1d
--- /dev/null
+++ b/plugins/help-user-buying/src/admin/HomeController.php
@@ -0,0 +1,209 @@
+setMemberId();
+
+ $member = Member::getMemberById($member_id);
+
+ $member_address = $this->getMemberAddress($member_id);
+
+ $catetory_menus = CategoryService::getCategoryMultiMenuSearch(['catlevel' => \Setting::get('shop.category')['cat_level']]);
+
+
+ if (app('plugins')->isEnabled('supplier')) {
+ $this->plugin_id[] = 92;
+ }
+
+ if (app('plugins')->isEnabled('net-car')) {
+ $this->plugin_id[] = 41;
+ }
+
+ $list = Goods::where('stock', '>', 0)->where('status', 1)->whereIn('plugin_id', $this->plugin_id)
+ ->with('hasManyGoodsCategory')->get();
+
+ if ($list->isEmpty()) {
+ throw new ShopException('无商品');
+ }
+
+ $list = $this->goodsMap($list, 'shop');
+
+ return view('Yunshop\HelpUserBuying::admin.index', [
+ 'goodsList' => $list->toArray(),
+ 'catetory_menus' => $catetory_menus,
+ 'store' => [],
+ 'member' => $member,
+ 'member_address' => $member_address,
+ 'route_url' => yzWebUrl('plugin.help-user-buying.admin.home.shop-index'),
+ 'order_url' => [
+ 'create_url' => yzWebUrl('plugin.help-user-buying.shop.controller.create.index'),
+ 'pre_url' => yzWebUrl('plugin.help-user-buying.shop.controller.goods-buy.index'),
+ ],
+ ]);
+ }
+
+ public function storeIndex()
+ {
+
+ $member_id = $this->setMemberId();
+
+
+ $store_id = intval(request()->input('store_id'));
+
+
+ $member = Member::getMemberById($member_id);
+
+ $member_address = $this->getMemberAddress($member_id);
+
+
+ $store = Store::uniacid()->whereId($store_id)->first();
+
+ //$is_goods = StoreGoods::whereStoreId($store_id)->get()->toArray();
+
+ $catetory_menus = \Yunshop\StoreCashier\common\services\CategoryService::getCategoryMenu(
+ [
+ 'store_id' => $store_id,
+ 'catlevel' => 2,
+ 'ids' => [],
+ ]
+ );
+
+ $list = StoreGoods::getGoodsList([], $this->store_id)->pluginId()->where('stock', '>', 0)->where('status', 1)
+ ->with('hasOneCategory')->where('stock', '>', 0)->get();
+
+ if ($list->isEmpty()) {
+ throw new ShopException('无商品');
+ }
+
+ $list = $this->goodsMap($list, 'store');
+
+ return view('Yunshop\HelpUserBuying::admin.index', [
+ 'goodsList' => $list->toArray(),
+ 'catetory_menus' => $catetory_menus,
+ 'store' => $store,
+ 'member' => $member,
+ 'member_address' => $member_address,
+ 'route_url' => yzWebUrl('plugin.help-user-buying.admin.home.store-index'),
+ 'order_url' => [
+ 'create_url' => yzWebUrl('plugin.help-user-buying.store.controller.create.index'),
+ 'pre_url' => yzWebUrl('plugin.help-user-buying.store.controller.goods-buy.index'),
+ ],
+ ]);
+ }
+
+ protected function goodsMap($list, $style = 'shop')
+ {
+ $list->map(function($goods) use ($style) {
+ $goods->thumb = yz_tomedia($goods->thumb);
+
+ if ($style == 'store') {
+ $goods->category_ids = $goods->hasOneCategory->category_ids;
+ } elseif ($style == 'shop') {
+ $goods->category_ids = $goods->hasManyGoodsCategory->implode('category_ids', ',');
+ }
+
+ });
+ return $list;
+ }
+
+
+ protected function setMemberId()
+ {
+ $member_id = intval(request()->input('uid'));
+
+ if (empty($member_id)) {
+ throw new ShopException('用户不存在');
+ }
+
+ Session::set('member_id', $member_id);
+
+ return $member_id;
+ }
+
+ public function getMemberAddress($uid)
+ {
+ if(\Setting::get('shop.trade.is_street')) {
+ $member_address = YzMemberAddress::uniacid()->whereUid($uid)->where('isdefault',1)->first();
+ if ($member_address) {
+ $member_address->province_id = Address::where('areaname',$member_address->province)->value('id');
+ $member_address->city_id = Address::where('areaname',$member_address->city)->value('id');
+ $member_address->district_id = Address::where('areaname',$member_address->district)->where('parentid', $member_address->city_id)->value('id');
+ $member_address->street_id = Street::where('parentid', $member_address->district_id)->where('areaname',$member_address->street)->value('id');
+ }
+ } else{
+ $member_address = MemberAddress::uniacid()->whereUid($uid)->where('isdefault',1)->first();
+
+ if ($member_address) {
+ $member_address->province_id = Address::where('areaname',$member_address->province)->value('id');
+ $member_address->city_id = Address::where('areaname',$member_address->city)->value('id');
+ $member_address->district_id = Address::where('areaname',$member_address->district)->where('parentid', $member_address->city)->value('id');
+ }
+ }
+
+
+ return !empty($member_address) ? $member_address : [];
+ }
+
+ public function select()
+ {
+
+ if (app('plugins')->isEnabled('store-cashier')) {
+ $store = \Yunshop\StoreCashier\common\models\Store::uniacid()->get()->toArray();
+ }
+
+ //预防万一先清空会员的member_id Session
+ Session::clear('member_id');
+
+ return view('Yunshop\HelpUserBuying::admin.select',[
+ 'store' => isset($store)?$store:[],
+ ])->render();
+ }
+
+ public function goodsIncrease()
+ {
+ $id = intval(\YunShop::request()->id);
+ $num = intval(\YunShop::request()->num);
+ $type = intval(\YunShop::request()->type);
+ $goods = Goods::where('status', 1)->find($id);
+
+ if (empty($goods)) {
+ return $this->errorJson('商品不存在或以下架',['code'=> 2]);
+ }
+
+ $new_num = $type ? $num : $num + 1;
+
+ if ($goods->stock < $new_num) {
+ return $this->successJson('最大',['data' => $goods->stock]);
+ }
+
+
+ return $this->successJson('ok',['data' => $new_num]);
+ }
+
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/admin/IndexController.php b/plugins/help-user-buying/src/admin/IndexController.php
new file mode 100644
index 00000000..08bedd88
--- /dev/null
+++ b/plugins/help-user-buying/src/admin/IndexController.php
@@ -0,0 +1,437 @@
+ 'shop',
+ 32 => 'store',
+ 92 => 'supplier',
+ ];
+
+ protected $plugin_id = [0];
+
+
+ public function index()
+ {
+ return view('Yunshop\HelpUserBuying::buying.select',[
+ 'store_enabled' => app('plugins')->isEnabled('store-cashier') ? 1 : 0,
+ 'supplier_enabled' => app('plugins')->isEnabled('supplier') ? 1 : 0,
+ ])->render();
+ }
+
+ public function getSource(Request $request)
+ {
+ if ($request->get('source') == 'store-cashier' && $request->get('source_input')){
+ $store = \Yunshop\StoreCashier\common\models\Store::uniacid()
+ ->select('id', 'store_name')
+ ->where('id', $request->source_input)
+ ->orWhere('store_name', 'like', '%' . $request->source_input . '%')
+ ->get()
+ ->toArray();
+ return $this->successJson('ok', ['stores' => $store]);
+ }
+
+ if ($request->get('source') == 'supplier' && $request->get('source_input')){
+ $supplier = \Yunshop\Supplier\common\models\Supplier::uniacid()
+ ->select('id', 'realname')
+ ->where('id', $request->source_input)
+ ->orWhere('realname', 'like', '%' . $request->source_input . '%')
+ ->get()
+ ->toArray();
+ return $this->successJson('ok', ['supplier' => $supplier]);
+ }
+
+ return $this->errorJson('参数不足或参数错误,请重试');
+ }
+
+ //平台代客下单
+ public function shopIndex()
+ {
+
+ $category_list = CategoryFactory::create('shop');
+
+
+ return view('Yunshop\HelpUserBuying::buying.goods', [
+ 'owner_id' => 0,
+ 'title' => '平台自营',
+ 'goods_url' => yzWebFullUrl('plugin.help-user-buying.admin.index.shopGoodsList'),
+ 'route_url' => yzWebFullUrl('plugin.help-user-buying.admin.index.shop-index'),
+ 'order_type' => 0,
+ 'category_level' => \Setting::get('shop.category.cat_level') == 3 ? 3:2,
+ 'category_list' => json_encode($category_list),
+ ]);
+ }
+
+
+ /**
+ * 获取平台商品列表
+ * @param string search['keyword'] 商品名称
+ * @param string search['category'] 商品分类id 多个用逗号拼接
+ * @return \Illuminate\Http\JsonResponse
+ * @throws AppException
+ */
+ public function shopGoodsList()
+ {
+
+ $search = request()->input('search');
+
+
+// if (app('plugins')->isEnabled('supplier')) {
+// $this->plugin_id[] = 92;
+// }
+
+ if (app('plugins')->isEnabled('net-car')) {
+ $this->plugin_id[] = 41;
+ }
+
+ $list = Goods::getGoodsList($search, $this->plugin_id)->paginate(15);
+
+
+ if ($list->isEmpty()) {
+ throw new AppException('无商品');
+ }
+
+ $list = $this->goodsMap($list);
+
+ return $this->successJson('list', $list);
+
+ }
+
+
+ //门店代客下单
+ public function storeIndex()
+ {
+
+ $store_id = intval(request()->input('store_id'));
+
+ $store = Store::uniacid()->where('id', $store_id)->first();
+
+
+ if (!$store) {
+ throw new ShopException('门店不存在');
+ }
+
+
+ $category_list = CategoryFactory::create('store', ['store_id'=> $store_id]);
+
+
+ return view('Yunshop\HelpUserBuying::buying.goods', [
+ 'owner_id' => $store_id,
+ 'title' => $store->store_name,
+ 'goods_url' => yzWebFullUrl('plugin.help-user-buying.admin.index.storeGoodsList'),
+ 'route_url' => yzWebFullUrl('plugin.help-user-buying.admin.index.store-index'),
+ 'order_type' => 32,
+ 'category_level' => '2',
+ 'category_list' => json_encode($category_list),
+ ]);
+ }
+
+
+ /**
+ * 获取门店商品列表
+ * @param int search['store_id'] 门店id
+ * @param string search['keyword'] 商品名称
+ * @param string search['category'] 商品分类id 多个用逗号拼接
+ * @return \Illuminate\Http\JsonResponse
+ * @throws AppException
+ */
+ public function storeGoodsList()
+ {
+
+ $search = request()->input('search');
+
+
+ if (empty(intval($search['owner_id']))) {
+ throw new AppException('门店不存在');
+ }
+
+ $list = StoreGoods::getGoodsList($search, $search['owner_id'])
+ ->orderBy('display_order', 'desc')->orderBy('yz_goods.id', 'desc')->paginate(15);
+
+
+ if ($list->isEmpty()) {
+ throw new AppException('无商品');
+ }
+
+ $list = $this->goodsMap($list);
+
+
+ return $this->successJson('list', $list);
+
+ }
+
+ //供应商代客下单
+ public function supplierIndex()
+ {
+
+ $supplier_id = intval(request()->input('supplier_id'));
+
+ $supplier = \Yunshop\Supplier\common\models\Supplier::uniacid()->where('id', $supplier_id)->first();
+ if (!$supplier) {
+ throw new ShopException('供应商不存在');
+ }
+
+ $category_list = CategoryFactory::create('shop');
+
+ return view('Yunshop\HelpUserBuying::buying.goods', [
+ 'owner_id' => $supplier_id,
+ 'title' => $supplier->realname,
+ 'goods_url' => yzWebFullUrl('plugin.help-user-buying.admin.index.supplierGoodsList'),
+ 'route_url' => yzWebFullUrl('plugin.help-user-buying.admin.index.shop-index'),
+ 'order_type' => 92,
+ 'category_level' => \Setting::get('shop.category.cat_level') == 3 ? 3:2,
+ 'category_list' => json_encode($category_list),
+ ]);
+ }
+
+ /**
+ * 获取供应商商品列表
+ * @param string search['keyword'] 商品名称
+ * @param string search['category'] 商品分类id 多个用逗号拼接
+ * @return \Illuminate\Http\JsonResponse
+ * @throws AppException
+ */
+ public function supplierGoodsList()
+ {
+
+ $search = request()->input('search');
+
+ if (empty(intval($search['owner_id']))) {
+ throw new AppException('供应商不存在');
+ }
+
+
+ $list = SupplierGoods::getGoodsList($search, $search['owner_id'])->paginate(15);
+
+ if ($list->isEmpty()) {
+ throw new AppException('无商品');
+ }
+
+ $list = $this->goodsMap($list);
+
+ return $this->successJson('list', $list);
+
+ }
+
+
+
+ //设置下单会员 Session 显示下单页
+ public function setMemberId()
+ {
+
+ $request = json_decode(request()->input('data'), true);
+
+ $order_type = $request['order_type'];
+
+ $member = Member::getMemberById($request['uid']);
+
+
+ if (empty($request['uid']) || empty($member)) {
+
+ //预防万一先清空会员的member_id Session
+ if (\YunShop::app()->getMemberId()) {
+
+ Session::clear('member_id');
+ }
+
+ return $this->errorJson('会员不存在');
+ }
+
+ Session::set('member_id', $member->uid);
+
+ $member->member_address = MemberAddressController::getMemberAddress($member->uid);
+
+
+ $deliveryMethod = $this->deliveryMethod($order_type,$request);
+
+ $needAddress = $this->needAddress($request);
+
+//dd($request,$deliveryMethod);
+ return view('Yunshop\HelpUserBuying::buying.order', [
+ 'member' => json_encode($member),
+ 'is_street' => \Setting::get('shop.trade.is_street')?:0,
+ 'order_url' => json_encode($this->getOrderUrl($order_type)),
+ 'request' => json_encode($request),
+ 'deliveryMethod' => json_encode($deliveryMethod),
+ 'needAddress' => $needAddress
+ ]);
+ }
+
+ //配送方式:司机配送
+ public function deliveryMethod($order_type,$request)
+ {
+ $arr = [];
+
+ //虚拟商品不需要配送方式 type:1-实体,2-虚拟
+ $goods_ids = array_column($request['goods'],'goods_id');
+ if (!Goods::uniacid()->selectRaw('1')->whereIn('id',$goods_ids)->where('type',1)->first()) {
+ return $arr;
+ }
+
+ if ($order_type == 32) {
+
+ $store = Store::uniacid()->where('id', $request['owner_id'])->first();
+
+ if (in_array(DispatchType::EXPRESS, $store->dispatch_type)) {
+ $arr[] = ['name' => '快递', 'value' => DispatchType::EXPRESS];
+ }
+
+ if (in_array(DispatchType::SELF_DELIVERY, $store->dispatch_type)) {
+ $arr[] = ['name' => '门店自提', 'value' => DispatchType::SELF_DELIVERY];
+ }
+
+ } else {
+ $arr[] = ['name' => '快递', 'value' => DispatchType::EXPRESS];
+ }
+
+// if ($order_type == 92) {
+// if (app('plugins')->isEnabled('delivery-driver')) {
+// $arr[] = ['name' => '司机配送', 'value' => 7];
+// }
+// }
+
+ return $arr;
+ }
+
+ /**
+ * 获取搜索会员
+ * @param string keyword 会员昵称、手机号、id
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function getSearchMember()
+ {
+
+ $keyword = request()->input('keyword');
+
+ $member = Member::uniacid()->searchLike($keyword)
+ ->whereHas('yzMember', function ($query) {
+ $query->whereNull('deleted_at');
+ })->with('yzMember')->get();
+
+ $member = set_medias($member, array('avatar', 'share_icon'));
+
+ return $this->successJson('member_search', $member);
+ }
+
+
+ //商品规格处理
+ protected function goodsMap($list)
+ {
+
+ $list->map(function($goodsModel){
+
+ $goodsModel->thumb = yz_tomedia($goodsModel->thumb);
+
+ if (!$goodsModel->hasManySpecs->isEmpty()) {
+ foreach ($goodsModel->hasManySpecs as &$spec) {
+ $spec['specitem'] = GoodsSpecItem::select('id', 'title', 'specid', 'thumb')->where('specid', $spec['id'])->orderBy('display_order', 'asc')->get();
+ }
+ }
+
+ if ($goodsModel->has_option) {
+ $goodsModel->min_price = $goodsModel->hasManyOptions->min("product_price");
+ $goodsModel->max_price = $goodsModel->hasManyOptions->max("product_price");
+ $goodsModel->stock = $goodsModel->hasManyOptions->sum('stock');
+ }
+
+ });
+
+ return $list->toArray();
+ }
+
+ /**
+ * 商品加减
+ * @param int id 商品id
+ * @param int option_id 商品规格id
+ * @param int num 商品增加数量
+ * @param int type 类型 0 直接取num, 在原数量上加一
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function goodsIncrease()
+ {
+ $id = intval(request()->input('id'));
+ $option_id = intval(request()->input('option_id'));
+ $new_num = intval(request()->input('num'));
+
+
+
+ if ($option_id) {
+ $goods = GoodsOption::uniacid()->whereHas('goods', function ($goods) use ($id) {
+ return $goods->where('id', $id)->where('status', 1);
+ })->find($option_id);
+
+ } else {
+ $goods = \app\common\models\Goods::where('status', 1)->find($id);
+
+ }
+
+ if (empty($goods)) {
+
+ $a = $option_id ?'规格ID('.$option_id.')':'';
+ return $this->errorJson('商品(ID:'.$id.')'. $a .' 不存在或以下架',['code'=> 2]);
+ }
+
+
+ if ($goods->stock < $new_num) {
+
+ return $this->successJson('最大',['code'=> 1, 'num' => $goods->stock]);
+ }
+
+
+ return $this->successJson('ok',['code'=> 2, 'num' => $new_num]);
+ }
+
+ protected function getOrderUrl($key)
+ {
+ $url = [
+ 0 => [
+ 'create_url' => yzApiUrl('plugin.help-user-buying.shop.controller.create.index'),
+ 'pre_url' => yzApiUrl('plugin.help-user-buying.shop.controller.goods-buy.index'),
+
+ ],
+ 32 => [
+ 'create_url' => yzApiUrl('plugin.help-user-buying.store.controller.create.index'),
+ 'pre_url' => yzApiUrl('plugin.help-user-buying.store.controller.goods-buy.index'),
+ ],
+ 92 => [
+ 'create_url' => yzApiUrl('plugin.help-user-buying.shop.controller.create.index'),
+ 'pre_url' => yzApiUrl('plugin.help-user-buying.shop.controller.goods-buy.index'),
+
+ ],
+ ];
+
+
+ return $url[$key];
+ }
+
+ protected function needAddress($request): int
+ {
+ $needAddress = 1;//1需要,2不需要
+ $goods_ids = array_column($request['goods'],'goods_id');
+ //need_address:0-需要收货地址,1不需要收货地址
+ if (Goods::uniacid()->select('id')->whereIn('id',$goods_ids)->where('type',2)->where('need_address',1)->count() == count($goods_ids)) {
+ $needAddress = 2;
+ }
+ return $needAddress;
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/admin/MemberAddressController.php b/plugins/help-user-buying/src/admin/MemberAddressController.php
new file mode 100644
index 00000000..b0c10ee9
--- /dev/null
+++ b/plugins/help-user-buying/src/admin/MemberAddressController.php
@@ -0,0 +1,230 @@
+input('type');
+
+ switch ($type) {
+ case 'province':
+ $addressData = Address::getProvince();
+ break;
+ case 'city':
+ $addressData = Address::getCityByParentId(\YunShop::request()->parentid);
+ break;
+ case 'district':
+ $addressData = Address::getAreaByParentId(\YunShop::request()->parentid);
+ break;
+ case 'street':
+ $addressData = Street::getStreetByParentId(\YunShop::request()->parentid);
+ break;
+ default:
+ $addressData = collect([]);
+ }
+ if ($addressData->isEmpty()) {
+ return $this->errorJson('未检测到数据!', $addressData);
+ }
+ return $this->successJson('成功', $addressData);
+ }
+
+
+ //会员默认地址
+ public static function getMemberAddress($uid)
+ {
+
+ if(\Setting::get('shop.trade.is_street')) {
+ $member_address = YzMemberAddress::uniacid()->whereUid($uid)->where('isdefault',1)->first();
+ if ($member_address) {
+ $member_address->province_id = Address::where('areaname',$member_address->province)->value('id');
+ $member_address->city_id = Address::where('areaname',$member_address->city)->where('parentid', $member_address->province_id)->value('id');
+ $member_address->district_id = Address::where('areaname',$member_address->district)->where('parentid', $member_address->city_id)->value('id');
+ $member_address->street_id = Street::where('parentid', $member_address->district_id)->where('areaname',$member_address->street)->value('id');
+ }
+ } else{
+ $member_address = MemberAddress::uniacid()->whereUid($uid)->where('isdefault',1)->first();
+
+ if ($member_address) {
+ $member_address->province_id = Address::where('areaname',$member_address->province)->value('id');
+ $member_address->city_id = Address::where('areaname',$member_address->city)->where('parentid', $member_address->province_id)->value('id');
+ $member_address->district_id = Address::where('areaname',$member_address->district)->where('parentid', $member_address->city_id)->value('id');
+ }
+ }
+
+
+ return !empty($member_address) ? $member_address->toArray() : [];
+ }
+
+ public function getMemberAddressList()
+ {
+ $member_id = intval(request()->input('member_id'));
+
+ $memberAddressRepository = app(MemberAddressRepository::class);
+
+ $memberAddressList = $memberAddressRepository->getAddressList($member_id);
+
+ foreach ($memberAddressList as $k => $member_address) {
+ if ($member_address) {
+ $member_address['province_id'] = Address::where('areaname',$member_address['province'])->value('id');
+ $member_address['city_id'] = Address::where('areaname',$member_address['city'])->where('parentid', $member_address['province_id'])->value('id');
+ $member_address['district_id'] = Address::where('areaname',$member_address['district'])->where('parentid', $member_address['city_id'])->value('id');
+ if ($member_address['street'] != '其他' && !empty($member_address['street'])) {
+ $member_address['street_id'] = Street::where('parentid', $member_address['district_id'])->where('areaname',$member_address['street'])->value('id');
+ } else {
+ $member_address['street_id'] = 0;
+ }
+
+ $member_address['address_info'] = implode(' ', array_filter([$member_address['province'], $member_address['city'], $member_address['district'], $member_address['street'], $member_address['address']]));
+
+ $memberAddressList[$k] = $member_address;
+ }
+ }
+
+ return $this->successJson('addressList', $memberAddressList);
+
+ }
+
+ public function createMemberAddress()
+ {
+ $data = request()->input('address');
+
+ $memberAddressRepository = app(MemberAddressRepository::class);
+
+ $member = Member::where('uid', $data['uid'])->first();
+ if (!$member) {
+ return $this->errorJson("UID[{$data['uid']}]该会员不存在");
+ }
+
+ if (!$data['username']) {
+ return $this->errorJson('收件人不能为空');
+ }
+
+ if (!$data['mobile']) {
+ return $this->errorJson('手机号不能为空');
+ }
+ if (!preg_match("/^[0-9]*$/", $data['mobile'])) {
+ return $this->errorJson('手机号请输入数字');
+ }
+
+ if (!$data['province']) {
+ return $this->errorJson('请选择省份');
+ }
+
+ if (!$data['city']) {
+ return $this->errorJson('请选择城市');
+ }
+
+ if (!$data['district']) {
+ return $this->errorJson('请选择区域');
+ }
+
+ if (!$data['address']) {
+ return $this->errorJson('请输入详细地址');
+ }
+
+ $createAddress = array_only($data, ['uid','username', 'mobile', 'province','city','district','address', 'street']);
+
+ $createAddress['uniacid'] = \YunShop::app()->uniacid;
+
+
+ $addressModel = $memberAddressRepository->fill($createAddress);
+
+ //dd($addressModel, $createAddress);
+
+ $validator = $addressModel->validator($addressModel->getAttributes());
+ if ($validator->fails()) {
+ return $this->errorJson($validator->messages()->first());
+ }
+ if (empty($addressModel->isdefault) && $data['isdefault']) {
+ $addressModel->isdefault = 1;
+ $memberAddressRepository->cancelDefaultAddress($addressModel->uid);
+ }
+ if ($addressModel->save()) {
+ return $this->successJson('新增收货地址成功', $addressModel->toArray());
+ } else {
+ return $this->errorJson("写入数据出错,请重试!");
+ }
+ }
+
+ //修改会员收获地址
+ public function editMemberAddress()
+ {
+
+ $address_id = trim(request()->input('id'));
+
+
+ $data = request()->input('address');
+
+ $memberAddressRepository = app(MemberAddressRepository::class);
+
+ $addressModel = $memberAddressRepository->getAddressById($address_id);
+ if (!$addressModel) {
+ return $this->errorJson("未找到地址数据或已删除");
+ }
+ if (!$data['username']) {
+ return $this->errorJson('收件人不能为空');
+ }
+
+ if (!$data['mobile']) {
+ return $this->errorJson('手机号不能为空');
+ }
+ if (!preg_match("/^[0-9]*$/", $data['mobile'])) {
+ return $this->errorJson('手机号请输入数字');
+ }
+
+ if (!$data['province']) {
+ return $this->errorJson('请选择省份');
+ }
+
+ if (!$data['city']) {
+ return $this->errorJson('请选择城市');
+ }
+
+ if (!$data['district']) {
+ return $this->errorJson('请选择区域');
+ }
+
+ if (!$data['address']) {
+ return $this->errorJson('请输入详细地址');
+ }
+
+ $updateAddress = array_only($data, ['username', 'mobile', 'province','city','district','address', 'street']);
+
+ $addressModel->fill($updateAddress);
+
+ $validator = $addressModel->validator($addressModel->getAttributes());
+ if ($validator->fails()) {
+ return $this->errorJson($validator->messages()->first());
+ }
+ if (empty($addressModel->isdefault) && $data['isdefault']) {
+ $addressModel->isdefault = 1;
+ $memberAddressRepository->cancelDefaultAddress($addressModel->uid);
+ }
+ if ($addressModel->save()) {
+ return $this->successJson('修改收货地址成功', $addressModel->toArray());
+ } else {
+ return $this->errorJson("写入数据出错,请重试!");
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/admin/UserMergePayController.php b/plugins/help-user-buying/src/admin/UserMergePayController.php
new file mode 100644
index 00000000..d6989597
--- /dev/null
+++ b/plugins/help-user-buying/src/admin/UserMergePayController.php
@@ -0,0 +1,173 @@
+validate([
+ 'order_ids' => 'required'
+ ]);
+
+ // 订单集合
+ $orders = $this->orders(request()->input('order_ids'));
+
+ // 用户余额
+ $member = $orders->first()->belongsToMember()->select(['credit2'])->first()->toArray();
+
+ // 生成支付记录 记录订单号,支付金额,用户,支付号
+ $orderPay = new PreOrderPay();
+ $orderPay->setOrders($orders);
+ $orderPay->store();
+
+ // 支付类型
+ $orderPaymentTypes = new HelpOrderPaymentTypes($orderPay);
+ $buttons = app('Payment')->setPaymentTypes($orderPaymentTypes)->getPaymentButton();
+
+ $data = ['order_pay' => $orderPay, 'member' => $member, 'buttons' => $buttons, 'typename' => ''];
+ return $this->successJson('成功', $data);
+ }
+
+ /**
+ * 支付的时候,生成支付记录的时候,通过订单ids获取订单集合
+ * @param $orderIds
+ * @return OrderCollection
+ * @throws AppException
+ */
+ private function orders($orderIds)
+ {
+ if (!is_array($orderIds)) {
+ $orderIds = explode(',', $orderIds);
+ }
+ array_walk($orderIds, function ($orderId) {
+ if (!is_numeric($orderId)) {
+ throw new AppException('(ID:' . $orderId . ')订单号id必须为数字');
+ }
+ });
+
+ $this->orders = OrderCollection::make(Order::select(['status', 'id', 'order_sn', 'price', 'uid'])->whereIn('id', $orderIds)->get());
+
+ if ($this->orders->count() != count($orderIds)) {
+ throw new AppException('(ID:' . implode(',', $orderIds) . ')未找到订单');
+ }
+ return $this->orders;
+ }
+
+
+
+
+ /**
+ * @return \Illuminate\Http\JsonResponse
+ * @throws AppException
+ * @throws \app\common\exceptions\PaymentException
+ * @throws \app\common\exceptions\ShopException
+ */
+ public function credit2()
+ {
+ if (\Setting::get('shop.pay.credit') == false) {
+ throw new AppException('商城未开启余额支付');
+ }
+
+
+ $orderPay = OrderPay::find(request()->input('order_pay_id'));
+ $result = $orderPay->getPayResult(PayFactory::PAY_CREDIT);
+ if (!$result) {
+ throw new AppException('余额扣除失败,请联系客服');
+ }
+ $orderPay->pay();
+
+ event(new ChargeComplatedEvent([
+ 'order_pay_id' => $orderPay->id
+ ]));
+
+
+ return $this->successJson('成功');
+ }
+
+ /**
+ * 货到付款
+ * @return \Illuminate\Http\JsonResponse
+ * @throws AppException
+ * @throws \app\common\exceptions\ShopException
+ */
+ public function COD()
+ {
+ $this->validate([
+ 'order_pay_id' => 'required|integer'
+ ]);
+ if (\Setting::get('shop.pay.COD') == false) {
+ throw new AppException('商城未开启货到付款');
+ }
+
+ //这个不知道是什么鬼
+// if (!is_null($event_arr = \app\common\modules\shop\ShopConfig::current()->get('plugin_delivery_pay_function'))) {
+// foreach ($event_arr as $v) {
+// $class = array_get($v, 'class');
+// $function = array_get($v, 'function');
+// $res = $class::$function(request()->input('order_pay_id'));
+// if (!$res['result']) {
+// throw new AppException($res['msg']);
+// }
+// if ($res['result'] && $res['data']['process'] == 'break') {
+// return $this->successJson('成功');
+// }
+// }
+// }
+
+ $orderPay = \app\frontend\models\OrderPay::find(request()->input('order_pay_id'));
+ $orderPay->getPayResult(PayFactory::PAY_COD);
+ $orderPay->pay();
+
+
+ return $this->successJson('成功');
+ }
+
+ /**
+ * 确认支付
+ * @return \Illuminate\Http\JsonResponse
+ * @throws AppException
+ * @throws \app\common\exceptions\ShopException
+ */
+ public function confirmPay()
+ {
+ $this->validate([
+ 'order_pay_id' => 'required|integer'
+ ]);
+
+ /**
+ * @var \app\frontend\models\OrderPay $orderPay
+ */
+ $orderPay = \app\frontend\models\OrderPay::find(request()->input('order_pay_id'));
+ $orderPay->getPayResult(PayFactory::CONFIRM_PAY);
+ $orderPay->pay();
+
+ return $this->successJson('成功');
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/common/CategoryFactory.php b/plugins/help-user-buying/src/common/CategoryFactory.php
new file mode 100644
index 00000000..7702ad5c
--- /dev/null
+++ b/plugins/help-user-buying/src/common/CategoryFactory.php
@@ -0,0 +1,65 @@
+select('id', 'name', 'enabled')->pluginId()->where('enabled', 1)->get();
+
+ $list->map(function($category) use($set) {
+ $childrens = Category::getChildrenCategorys($category->id,$set)->select('id', 'name', 'enabled')->get()->toArray();
+ foreach ($childrens as $key => &$children) {
+ if ($set['cat_level'] == 3 && $children['has_many_children']) {
+ $children['childrens'] = $children['has_many_children'];
+ } else {
+ $children['childrens'] = [];
+ }
+ }
+ $category->childrens = $childrens;
+
+ });
+
+ return $list;
+ }
+
+ protected static function storeCategory($params)
+ {
+ $list = storeCategory::getCategory($params)->get();
+
+ $list->map(function($category) use ($params) {
+
+ $category->childrens = storeCategory::getChildrenCategory($category->id, $params)->get()->toArray();
+
+ });
+
+ return $list;
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/common/MenuHook.php b/plugins/help-user-buying/src/common/MenuHook.php
new file mode 100644
index 00000000..0d9fa8e8
--- /dev/null
+++ b/plugins/help-user-buying/src/common/MenuHook.php
@@ -0,0 +1,413 @@
+ '代客下单',
+ 'url' => 'plugin.help-user-buying.admin.index.index', //url 可以填写http 也可以直接写路由
+ 'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
+ 'permit' => 1,//如果不设置则不会做权限检测
+ 'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
+ 'top_show' => 0,
+ 'left_first_show' => $left_show,
+ 'left_second_show' => 0,
+ 'icon' => 'fa-child',//菜单图标
+ 'type' => 'industry',
+ 'list_icon' => 'help_user_buying',
+ 'parents' => [],
+ 'child' => [
+// 'help-user-buying-select' => [
+// 'name' => '选择基地',
+// 'permit' => 1,
+// 'menu' => 1,
+// 'icon' => '',
+// 'url' => 'plugin.help-user-buying.admin.home.select',
+// 'url_params'=> '',
+// 'parents' => ['help_user_buying'],
+// 'child' => []
+// ],
+ 'help-user-buying-index' => [
+ 'name' => '选择订单类型',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-order' => [
+ 'name' => '下单页',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.set-member-id',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-shop-index' => [
+ 'name' => '商城商品下单',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.shop-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-shop-goods-list' => [
+ 'name' => '商城商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.shopGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ 'help-user-buying-shop-goods-buy' => [
+ 'name' => '商城订单预下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ 'help-user-buying-shop-create' => [
+ 'name' => '商城订单下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-store-index' => [
+ 'name' => '门店商品下单',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.store-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-store-goods-list' => [
+ 'name' => '门店商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.storeGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-store-goods-buy' => [
+ 'name' => '门店订单预下单',
+ 'url' => 'plugin.help-user-buying.store.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-store-create' => [
+ 'name' => '门店订单下单',
+ 'url' => 'plugin.help-user-buying.store.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-supplier-index' => [
+ 'name' => '供应商商品下单',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.supplier-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-store-goods-list' => [
+ 'name' => '供应商商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.supplierGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-supplier-goods-buy' => [
+ 'name' => '供应商订单预下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-supplier-create' => [
+ 'name' => '供应商订单下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-goods-increase' => [
+ 'name' => '商品加减',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.goods-increase',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+// 'help-user-buying-delivery-method' => [
+// 'name' => '配送方式',
+// 'permit' => 0,
+// 'menu' => 0,
+// 'icon' => '',
+// 'url' => 'plugin.help-user-buying.admin.index.delivery-method',
+// 'url_params'=> '',
+// 'parents' => ['help_user_buying'],
+// 'child' => []
+// ],
+ 'help-user-buying-get-search-member' => [
+ 'name' => '获取搜索会员',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.getSearchMember',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-user-merge-pay' => [
+ 'name' => '支付',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-user-merge-pay-credit2' => [
+ 'name' => '余额支付',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.credit2',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ 'help-user-buying-user-merge-pay-COD' => [
+ 'name' => '货到付款',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.COD',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ ]
+ ],
+ 'help-user-buying-address' => [
+ 'name' => '获取地址数据',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.member-address.get-address',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ ]
+ ];
+
+ return $menu;
+ }
+
+ //门店后台显示列表
+ public static function storeMenu()
+ {
+ return [
+ 'name' => '代客下单',
+ 'url' => 'plugin.help-user-buying.admin.index.index', //url 可以填写http 也可以直接写路由
+ 'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
+ 'permit' => 0,//如果不设置则不会做权限检测
+ 'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
+ 'top_show' => 0,
+ 'left_first_show' => 1,
+ 'left_second_show' => 0,
+ 'icon' => 'fa-child',//菜单图标
+ 'type' => 'industry',
+ 'list_icon' => 'help_user_buying',
+ 'parents' => [],
+ 'child' => [
+ 'help-user-buying-index' => [
+ 'name' => '选择订单类型',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-order' => [
+ 'name' => '下单页',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.set-member-id',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-shop-index' => [
+ 'name' => '商城商品下单',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.shop-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-shop-goods-list' => [
+ 'name' => '商城商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.shopGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ 'help-user-buying-shop-goods-buy' => [
+ 'name' => '商城订单预下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ 'help-user-buying-shop-create' => [
+ 'name' => '商城订单下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-shop-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-store-index' => [
+ 'name' => '门店商品下单',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.store-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-store-goods-list' => [
+ 'name' => '门店商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.storeGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-store-goods-buy' => [
+ 'name' => '门店订单预下单',
+ 'url' => 'plugin.help-user-buying.store.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-store-create' => [
+ 'name' => '门店订单下单',
+ 'url' => 'plugin.help-user-buying.store.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-supplier-index' => [
+ 'name' => '供应商商品下单',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.supplier-index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-store-goods-list' => [
+ 'name' => '供应商商品列表',
+ 'url' => 'plugin.help-user-buying.admin.index.supplierGoodsList',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-supplier-goods-buy' => [
+ 'name' => '供应商订单预下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.goods-buy.index',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ 'help-user-buying-supplier-create' => [
+ 'name' => '供应商订单下单',
+ 'url' => 'plugin.help-user-buying.shop.controller.create.index',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-store-index'],
+ ],
+ ]
+ ],
+ 'help-user-buying-goods-increase' => [
+ 'name' => '商品加减',
+ 'permit' => 0,
+ 'menu' => 0,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.goods-increase',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-get-search-member' => [
+ 'name' => '获取搜索会员',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.index.getSearchMember',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ 'help-user-buying-user-merge-pay' => [
+ 'name' => '支付',
+ 'permit' => 1,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.index',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => [
+ 'help-user-buying-user-merge-pay-credit2' => [
+ 'name' => '余额支付',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.credit2',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ 'help-user-buying-user-merge-pay-COD' => [
+ 'name' => '货到付款',
+ 'url' => 'plugin.help-user-buying.admin.user-merge-pay.COD',
+ 'permit' => 1,
+ 'menu' => 0,
+ 'parents' => ['help_user_buying', 'help-user-buying-user-merge-pay'],
+ ],
+ ]
+ ],
+ 'help-user-buying-address' => [
+ 'name' => '获取地址数据',
+ 'permit' => 0,
+ 'menu' => 1,
+ 'icon' => '',
+ 'url' => 'plugin.help-user-buying.admin.member-address.get-address',
+ 'url_params'=> '',
+ 'parents' => ['help_user_buying'],
+ 'child' => []
+ ],
+ ]
+ ];
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/common/OrderObserver.php b/plugins/help-user-buying/src/common/OrderObserver.php
new file mode 100644
index 00000000..75ded74d
--- /dev/null
+++ b/plugins/help-user-buying/src/common/OrderObserver.php
@@ -0,0 +1,49 @@
+search($search);
+
+ $model->where('stock', '>', 0)->where('status', 1)->whereIn('plugin_id', $plugin_ids);
+
+ $model->with(['hasManySpecs' => function ($query) {
+ return $query->select('id', 'goods_id', 'title', 'description');
+ }])->with(['hasManyOptions' => function ($query) {
+ return $query->select('id', 'goods_id', 'title', 'thumb', 'product_price', 'market_price', 'stock', 'specs', 'weight');
+ }]);
+
+
+ $model->orderBy('display_order', 'desc')->orderBy('yz_goods.id', 'desc');
+
+
+ return $model;
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/models/GoodsOption.php b/plugins/help-user-buying/src/models/GoodsOption.php
new file mode 100644
index 00000000..0f89161a
--- /dev/null
+++ b/plugins/help-user-buying/src/models/GoodsOption.php
@@ -0,0 +1,18 @@
+belongsTo( \app\common\models\Goods::class, 'goods_id', 'id');
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/shop/controller/CreateController.php b/plugins/help-user-buying/src/shop/controller/CreateController.php
new file mode 100644
index 00000000..ee4a76ba
--- /dev/null
+++ b/plugins/help-user-buying/src/shop/controller/CreateController.php
@@ -0,0 +1,26 @@
+bind('Goods', function ($goodsManager, $attributes) {
+ return new Goods($attributes);
+ });
+
+ app('GoodsManager')->bind('GoodsOption', function ($goodsManager, $attributes) {
+ return new GoodsOption($attributes);
+ });
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/shop/controller/GoodsBuyController.php b/plugins/help-user-buying/src/shop/controller/GoodsBuyController.php
new file mode 100644
index 00000000..8a509114
--- /dev/null
+++ b/plugins/help-user-buying/src/shop/controller/GoodsBuyController.php
@@ -0,0 +1,51 @@
+bind('Goods', function ($goodsManager, $attributes) {
+ return new Goods($attributes);
+ });
+
+ app('GoodsManager')->bind('GoodsOption', function ($goodsManager, $attributes) {
+ return new GoodsOption($attributes);
+ });
+ }
+
+ protected function getMemberCarts()
+ {
+ $goods_params = json_decode(request()->input('goods'),true);
+
+
+ $result = collect($goods_params)->map(function ($memberCart) {
+ return MemberCartService::newMemberCart($memberCart);
+ });
+ $memberCarts = new MemberCartCollection($result);
+ $memberCarts->loadRelations();
+ return $memberCarts;
+ }
+
+ protected function validateParam(){
+
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/store/controller/CreateController.php b/plugins/help-user-buying/src/store/controller/CreateController.php
new file mode 100644
index 00000000..4489ab28
--- /dev/null
+++ b/plugins/help-user-buying/src/store/controller/CreateController.php
@@ -0,0 +1,16 @@
+input('goods'),true);
+
+
+ $result = collect($goods_params)->map(function ($memberCart) {
+ return MemberCartService::newMemberCart($memberCart);
+ });
+ $memberCarts = new MemberCartCollection($result);
+ $memberCarts->loadRelations();
+ return $memberCarts;
+
+ }
+
+ protected function validateParam()
+ {
+ $this->validate([
+ 'store_id' => 'required|integer|min:0',
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/store/controller/OperationController.php b/plugins/help-user-buying/src/store/controller/OperationController.php
new file mode 100644
index 00000000..3e17ed3d
--- /dev/null
+++ b/plugins/help-user-buying/src/store/controller/OperationController.php
@@ -0,0 +1,62 @@
+input('pay_type');
+ $order_id = request()->input('order_id');
+
+
+ if (!in_array($pay_type, [PayType::COD, PayType::CREDIT, PayType::BACKEND])) {
+ throw new AppException('支付方式不支持');
+ }
+
+ if ($pay_type == PayType::CREDIT) {
+ return $this->buyingCredit2();
+ }
+ $this->param['pay_type_id'] = $pay_type;
+ OrderService::orderPay($this->param);
+ return $this->successJson();
+
+ }
+
+ public function buyingCredit2()
+ {
+ if (\Setting::get('shop.pay.credit') == false) {
+ throw new AppException('商城未开启余额支付');
+
+ }
+
+ $data = [
+ 'member_id' => $this->order->uid,
+ 'remark' => '代客下单使用余额支付订单:'.$this->order->id,
+ 'source' => ConstService::SOURCE_CONSUME,
+ 'relation' => $this->order->order_sn,
+ 'operator' => ConstService::OPERATOR_SHOP,
+ 'operator_id' => ConstService::OPERATOR_ORDER,
+ 'change_value' => $this->order->price,
+ ];
+
+ $result = (new BalanceChange())->consume($data);
+
+ if ($result === true) {
+ OrderService::orderPay(['order_id' => $this->order->id, 'order_pay_id' => 0, 'pay_type_id' => PayType::CREDIT]);
+ return $this->successJson();
+ } else {
+ throw new AppException($result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/store/models/Category.php b/plugins/help-user-buying/src/store/models/Category.php
new file mode 100644
index 00000000..eb819e98
--- /dev/null
+++ b/plugins/help-user-buying/src/store/models/Category.php
@@ -0,0 +1,50 @@
+where('enabled', 1);
+
+ $model->where('parent_id', 0);
+
+ if ($search['store_id']) {
+ $model->whereHas('hasOneStoreGoodsCategory', function ($storeGoodsCategory) use ($search) {
+ return $storeGoodsCategory->byStoreId($search['store_id']);
+
+ });
+ }
+
+ $model->orderBy('display_order', 'asc');
+
+ return $model;
+ }
+
+
+ /**
+ * @param $parentId
+ * @param $set
+ * @return mixed
+ */
+ public static function getChildrenCategory($parentId, $search)
+ {
+ $model = self::select('id', 'name', 'enabled');
+ $model->where('parent_id', $parentId);
+ $model->where('enabled', 1);
+
+ if ($search['store_id']) {
+ $model->whereHas('hasOneStoreGoodsCategory', function ($storeGoodsCategory) use ($search) {
+ return $storeGoodsCategory->byStoreId($search['store_id']);
+
+ });
+ }
+
+ $model->orderBy('display_order', 'asc');
+
+ return $model;
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/store/models/Store.php b/plugins/help-user-buying/src/store/models/Store.php
new file mode 100644
index 00000000..e90bce4d
--- /dev/null
+++ b/plugins/help-user-buying/src/store/models/Store.php
@@ -0,0 +1,12 @@
+hasOne(GoodsCategory::class, 'goods_id', 'id');
+ }
+
+ public static function getGoodsList($search, $storeId = 0)
+ {
+ return self::select()->search($search)->hasOneStoreGoods($storeId)
+ ->pluginId()->where('stock', '>', 0)->where('status', 1)->where('type', 1)
+ ->with(['hasManySpecs' => function ($query) {
+ return $query->select('id', 'goods_id', 'title', 'description');
+ }])->with(['hasManyOptions' => function ($query) {
+ return $query->select('id', 'goods_id', 'title', 'thumb', 'product_price', 'market_price', 'stock', 'specs', 'weight');
+ }]);
+ }
+
+ public function scopePluginId($query, $pluginId = Store::PLUGIN_ID)
+ {
+ return $query->where('plugin_id', $pluginId);
+ }
+
+ public function scopeHasOneStoreGoods($query, $storeId)
+ {
+ return $query->whereHas('hasOneStoreGoods', function($storeGoods)use($storeId){
+ if ($storeId) {
+ $storeGoods->byStoreId($storeId);
+ }
+ });
+ }
+
+ public function hasManySpecs()
+ {
+ return $this->hasMany('app\common\models\GoodsSpec', 'goods_id', 'id');
+ }
+
+ public function hasManyOptions()
+ {
+ return $this->hasMany(GoodsOption::class, 'goods_id', 'id');
+ }
+
+ public function hasOneStoreGoods()
+ {
+ return $this->hasOne(\Yunshop\StoreCashier\store\models\StoreGoods::class, 'goods_id', 'id');
+ }
+
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/src/supplier/models/SupplierGoods.php b/plugins/help-user-buying/src/supplier/models/SupplierGoods.php
new file mode 100644
index 00000000..3d4a4daa
--- /dev/null
+++ b/plugins/help-user-buying/src/supplier/models/SupplierGoods.php
@@ -0,0 +1,64 @@
+uniacid()->search($search);
+
+ $model->where('yz_goods.stock', '>', 0)->where('yz_goods.status', 1)->pluginId()->where('type', 1);
+
+ $model->with(['hasManySpecs' => function ($query) {
+ return $query->select('id', 'goods_id', 'title', 'description');
+ }])->with(['hasManyOptions' => function ($query) {
+ return $query->select('id', 'goods_id', 'title', 'thumb', 'product_price', 'market_price', 'stock', 'specs', 'weight');
+ }]);
+
+ $model->joinSupplierGoods(['supplier_id'=> $supplier_id]);
+
+ $model->orderBy('yz_goods.display_order', 'desc')->orderBy('yz_goods.id', 'desc');
+
+
+ return $model;
+ }
+
+ public function scopeJoinSupplierGoods($goods_builder, $params)
+ {
+ $goods_builder->join('yz_supplier_goods', function ($join) use ($params) {
+ $join->on('yz_goods.id','=','yz_supplier_goods.goods_id')->where('yz_supplier_goods.supplier_id', $params['supplier_id']);
+ });
+ return $goods_builder;
+ }
+
+ public function scopeUniacid($query)
+ {
+ return $query->where('yz_goods.uniacid', \YunShop::app()->uniacid);
+ }
+
+ public function scopeIsPlugin($query)
+ {
+ return $query->where('yz_goods.is_plugin', 1);
+ }
+
+ public function scopePluginId($query, $pluginId = 92)
+ {
+ return $query->where('yz_goods.plugin_id', $pluginId);
+ }
+
+ public function hasManySpecs()
+ {
+ return $this->hasMany('app\common\models\GoodsSpec', 'goods_id', 'id');
+ }
+
+ public function hasManyOptions()
+ {
+ return $this->hasMany(GoodsOption::class, 'goods_id', 'id');
+ }
+}
\ No newline at end of file
diff --git a/plugins/help-user-buying/views/admin/index.blade.php b/plugins/help-user-buying/views/admin/index.blade.php
new file mode 100644
index 00000000..e6bfb73f
--- /dev/null
+++ b/plugins/help-user-buying/views/admin/index.blade.php
@@ -0,0 +1,682 @@
+@extends('layouts.base')
+
+@section('content')
+
+@section('title', trans('代客下单'))
+
+@section('css')
+
+@endsection
+
+
+
+
+
@if(empty($store)) 平台自营 @else 门店:{{$store['store_name']}} @endif
+
+
+
+
+
+
+
+
+
+ 订单信息
+
+
+
+
+
+
+ | 商品名称 |
+ 价格 |
+ 数量 |
+ 金额 |
+ 删除 |
+
+
+
+
+
+
+
+
+
+
+
+
+ 会员信息
+
+
+
+
+ {{--
--}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@include('Yunshop\HelpUserBuying::admin.payform')
+
+
+
+
+@endsection
\ No newline at end of file
diff --git a/plugins/help-user-buying/views/admin/payform.blade.php b/plugins/help-user-buying/views/admin/payform.blade.php
new file mode 100644
index 00000000..d5d554c3
--- /dev/null
+++ b/plugins/help-user-buying/views/admin/payform.blade.php
@@ -0,0 +1,98 @@
+
+
+
+
\ No newline at end of file
diff --git a/plugins/help-user-buying/views/admin/select.blade.php b/plugins/help-user-buying/views/admin/select.blade.php
new file mode 100644
index 00000000..fd527511
--- /dev/null
+++ b/plugins/help-user-buying/views/admin/select.blade.php
@@ -0,0 +1,158 @@
+@extends('layouts.base')
+
+@section('content')
+@section('title', trans('代客下单'))
+
+
+
+
+@endsection
diff --git a/plugins/help-user-buying/views/buying/goods.blade.php b/plugins/help-user-buying/views/buying/goods.blade.php
new file mode 100644
index 00000000..953310ab
--- /dev/null
+++ b/plugins/help-user-buying/views/buying/goods.blade.php
@@ -0,0 +1,613 @@
+@extends('layouts.base')
+@section('title', "代客下单")
+@section('content')
+
+
+
+
+ 返回选择
+ {{--[[store.id==0?'平台自营':store.store_name]]--}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+ [[scope.row.title]]
+
+
+
+
+
+
+
+ 选择
+
+
+
+
+
+
+
+
+
+
+
+ 订单信息
+ 清空购物车
+
+
+
+
+
+
+
[[scope.row.title]]
+
[ [[scope.row.option_title]] ]
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+
+
+
+ (不包含运费)
+ 合计:[[total_money]]元
+ 结算
+
+
+
+
+
+
+
+
已选会员:
+
+
![]()
+
+
+
[[member.nickname]]
+
[[member.mobile]]
+
清除选择
+
+
+
+
+
+ 搜索
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 选择
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[item.title]]
+
+
+
+ [[item1.title]]
+
+
+
+
+
+
+
+
+
+@endsection
diff --git a/plugins/help-user-buying/views/buying/order.blade.php b/plugins/help-user-buying/views/buying/order.blade.php
new file mode 100644
index 00000000..71634a79
--- /dev/null
+++ b/plugins/help-user-buying/views/buying/order.blade.php
@@ -0,0 +1,848 @@
+@extends('layouts.base')
+@section('title', "代客下单")
+@section('content')
+
+
+
+
+ 返回选择
+ [[goods.title?goods.title:'平台自营']]
+
+
+
+
+
+
+ 会员信息
+
+
+
+
+
+
+
+
+
+ [[item.name]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 其他地址
+ 新增地址
+
+
+
+
+
+
+
+
+
+ 订单信息
+
+
+
+
+
+
+
+
+
+
+ [[scope.row.goods_option_title?scope.row.goods_option_title:'']]
+
+
+
+
+ [[scope.row.goods_price/scope.row.total]]
+
+
+
+
+
+
+
+
+ 优惠抵扣信息
+
+
+
+
可用[[item1.coin]][[item1.name]] 抵扣[[item1.amount]]元
+
+
+
+
+
+
+
+
+
+
+ 优惠抵扣信息
+
+
+
+
+
优惠券 [[total_coupons]]张可用
+
+
+ [[used_coupons==0?'未使用':'已使用'+used_coupons+'张']]
+
+
+
+
+
+
+ [[item.name]]:¥[[item.amount]]
+
+ 合计:¥[[total_price]]
+
+
+
立即下单
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 不限
+ 满[[scope.row.belongs_to_coupon.enough可用]]
+ 立减[[scope.row.belongs_to_coupon.deduct]]元
+ 打[[scope.row.belongs_to_coupon.discount]]折
+
+
+
+
+
+
+
+
+
+
+
+
+
+
会员余额:[[pay.credit2]]
+
支付流水号:[[pay.pay_sn]]
+
支付金额:[[pay.amount]]元
+
+ [[item1.name]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 选择
+ 编辑
+
+
+
+
+
+
+
+
+
+
+
+
+ @include('Yunshop\HelpUserBuying::buying.template.editMemberAddress')
+
+@endsection
diff --git a/plugins/help-user-buying/views/buying/select.blade.php b/plugins/help-user-buying/views/buying/select.blade.php
new file mode 100644
index 00000000..4a596801
--- /dev/null
+++ b/plugins/help-user-buying/views/buying/select.blade.php
@@ -0,0 +1,163 @@
+@extends('layouts.base')
+@section('title', "代客下单")
+@section('content')
+
+
+
+
+
+
+ 平台自营
+ 门店
+ 供应商
+
+
+
+
+
+
+
+
+
+
+
+
+ 下一步
+
+
+
+
+@endsection
diff --git a/plugins/help-user-buying/views/buying/template/editMemberAddress.blade.php b/plugins/help-user-buying/views/buying/template/editMemberAddress.blade.php
new file mode 100644
index 00000000..2f337173
--- /dev/null
+++ b/plugins/help-user-buying/views/buying/template/editMemberAddress.blade.php
@@ -0,0 +1,356 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 是
+ 否
+
+
+
+
+
+
+
+
+
+
+