diff --git a/app/admin/controller/RetailDescribe.php b/app/admin/controller/RetailDescribe.php index 7780931e..820e4989 100644 --- a/app/admin/controller/RetailDescribe.php +++ b/app/admin/controller/RetailDescribe.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\admin\controller; use app\store\model\RetailDescribe as retDescribeModel; +use app\common\enum\RetailDescribeEnum; class RetailDescribe extends Controller { @@ -47,4 +48,9 @@ class RetailDescribe extends Controller return $this->renderError($model->getError() ?: '删除失败'); } + public function getPlate(){ + $list = RetailDescribeEnum::$version; + return $this->renderSuccess(compact('list')); + } + } \ No newline at end of file diff --git a/app/api/controller/Retail.php b/app/api/controller/Retail.php index 15190e16..70fa79e2 100644 --- a/app/api/controller/Retail.php +++ b/app/api/controller/Retail.php @@ -11,12 +11,14 @@ declare (strict_types=1); namespace app\api\controller; +use app\admin\controller\RetailDescribe; use think\response\Json; use app\api\model\Retail as RetailModel; use app\api\model\RetailOrder as RetailOrderModel; use app\api\model\Agreement as AgreementModel; use app\common\model\RetailDescribe as RetailDescribeModel; use app\api\service\order\Checkout as CheckoutService; +use app\api\service\Retail as RetailService; use app\api\service\User as UserService; use app\common\enum\RetailDescribeEnum; @@ -65,77 +67,71 @@ class Retail extends Controller } $model =new \app\api\service\Retail(); $list = $model->userCenter($client); - $list['retail'] = '
- 1、客户直接在商城查看价格,快速比价、下单 + $list['retail'] = '
+ 1-客户直接在商城查看价格,快速比价、下单
-- 2、所有会员、分销数字化管理 +
+ 2-所有会员、分销数字化管理
-- 3、所有订单,调货记录,物流状态实时查询 +
+ 3-所有订单,调货记录,物流状态实时查询
-- 4、供应链资源快速对接 +
+ 4-供应链资源快速对接
-- 5、商品数据快速上架,商城之间数据实时传输 +
+ 5-商品数据快速上架,商城之间数据实时传输
-- 6、商品市场价实时自动更新 +
+ 6-商品市场价实时自动更新
-- 7、货款到账时间支持当天或隔天,支付费率低 +
+ 7-货款到账时间支持当天或隔天,支付费率低
-+
至千分之2.x
-- 8、支持到店自提、同城闪送 +
+ 8-支持到店自提、同城闪送
-- 9、促进清洗、安装、维修、回收、租赁服务与产品销售一体化 +
+ 9-促进清洗、安装、维修、回收、租赁服务与产品销售一体化
-- 10、促进本地商家联盟数字化平台化发展 -
-
-
+
+ 10-促进本地商家联盟数字化平台化发展
'; - $list['wholesale'] = '- 1、客户直接在商城查看价格,快速比价、下单 -
-- 2、所有会员、分销数字化管理 + $list['wholesale'] = '
+ 1-采购代发商家实名注册认证,在线直接下单
-- 3、所有订单,调货记录,物流状态实时查询 +
+ 2-认证商家、服务商数字化管理
-- 4、供应链资源快速对接 +
+ 3-所有订单,发货记录,物流状态实时查询
-- 5、商品数据快速上架,商城之间数据实时传输 +
+ 4-所有调货记录在线实时查看
-- 6、商品市场价实时自动更新 +
+ 5-审单实时做电话、地址校验比对,避免平台单
-- 7、货款到账时间支持当天或隔天,支付费率低 +
+ 6-供应链资源快速对接
-- 至千分之2.x +
+ 7-商品数据快速上架,商城之间商品数据实时传输
-- 8、支持到店自提、同城闪送 +
+ 8-商品市场价实时自动更新
-- 9、促进清洗、安装、维修、回收、租赁服务与产品销售一体化 +
+ 9-货款到账时间支持当天或隔天,支付费率低
-- 10、促进本地商家联盟数字化平台化发展 +
+ 至千分之2.x
-
-
+
+ 10-供应商、服务商入驻,销售和推广效益提升
'; return $this->renderSuccess(compact('list')); } @@ -179,4 +175,24 @@ class Retail extends Controller } + /** + * 交易查询 + * @param string $outTradeNo 商户订单号 + * @param string $method 支付方式 + * @param string $client 指定的客户端 + * @return Json + * @throws \cores\exception\BaseException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function tradeQuery(string $outTradeNo, string $method, string $client): Json + { + $RechargeService = new RetailService; + $result = $RechargeService->setMethod($method)->setClient($client)->tradeQuery($outTradeNo); + $message = $result ? '恭喜您,余额充值成功' : ($RechargeService->getError() ?: '很抱歉,订单未支付,请重新发起'); + return $this->renderSuccess(['isPay' => $result], $message); + } + + } \ No newline at end of file diff --git a/app/api/service/Notify.php b/app/api/service/Notify.php index 49452cd3..020152ec 100644 --- a/app/api/service/Notify.php +++ b/app/api/service/Notify.php @@ -83,6 +83,7 @@ class Notify $platformCertificateFilePath = PaymentTemplateModel::realPathCertFile( PaymentMethodEnum::WECHAT, $fileName, $templateInfo['store_id'] ); + // 验证异步通知是否合法并获取第三方支付交易订单号 $V3 = new WechatPaymentV3(); $outTradeNo = $V3->notify($apiv3Key, $platformCertificateFilePath); @@ -211,6 +212,17 @@ class Notify ->setPaymentData($paymentData) ->handle(); } + //订单支付成功事件(开通商城(批发零售商城)) + if ($tradeInfo['order_type'] == OrderTypeEnum::RETAIL || $tradeInfo['order_type'] == OrderTypeEnum::SALE) { + $service = new Retail\PaySuccess(); + $service->setOrderNo($tradeInfo['order_no']) + ->setMethod($tradeInfo['pay_method']) + ->setTradeId($tradeInfo['trade_id']) + ->setPaymentData($paymentData) + ->handle(); + } + + Log::append('Notify-orderPaySucces', ['message' => '订单支付成功']); } catch (\Throwable $e) { // 记录错误日志 diff --git a/app/api/service/Retail/PaySuccess.php b/app/api/service/Retail/PaySuccess.php index e402558b..064a17f3 100644 --- a/app/api/service/Retail/PaySuccess.php +++ b/app/api/service/Retail/PaySuccess.php @@ -220,7 +220,7 @@ class PaySuccess extends BaseService UserModel::setDecBalance((int)$orderInfo['user_id'], (float)$orderInfo['pay_price']); // 新增余额变动记录 $type = SceneEnum::BUY_SHOP; - if ($this->type == IdentityEnum::DEALER) { + if ($this->type == SceneEnum::DEALER) { $type = SceneEnum::DEALER; } BalanceLogModel::add($type, [ diff --git a/app/api/service/Retail/Payment.php b/app/api/service/Retail/Payment.php index f53548d9..b04ce087 100644 --- a/app/api/service/Retail/Payment.php +++ b/app/api/service/Retail/Payment.php @@ -100,11 +100,11 @@ class Payment extends BaseService // 构建第三方支付请求的参数 $payment = $this->unifiedorder($extra); // 记录第三方交易信息 - // $order_type = OrderTypeEnum::MEMBER;//开通会员 - // if ($this->orderInfo['order_type'] == IdentityEnum::DEALER) { - // $order_type = OrderTypeEnum::DEALER;//开通分销商 - // } - // $this->recordPaymentTrade($payment, $order_type); + $order_type = OrderTypeEnum::RETAIL;//开通零售商城 + if ($this->orderInfo['order_type'] == 20) { + $order_type = OrderTypeEnum::SALE;//开通批发商城 + } + $this->recordPaymentTrade($payment, $order_type); // 返回结果 return compact('payment'); } diff --git a/app/api/service/Store.php b/app/api/service/Store.php index 43249b6c..b46fff8e 100644 --- a/app/api/service/Store.php +++ b/app/api/service/Store.php @@ -196,7 +196,9 @@ class Store extends BaseService public function getStore() { - $storeList = Db::query('select shop_id,shop_name,longitude,latitude from yoshop_store_shop where status = 1 and is_delete= 0'); + $storeId = $this->storeId; + $storeList = Db::query('select shop_id,shop_name,longitude,latitude from yoshop_store_shop where status = 1 and is_delete= 0 AND store_id = ?', + [$storeId]); return $storeList; } diff --git a/app/common/enum/OrderType.php b/app/common/enum/OrderType.php index 45bfdbbf..710b00e4 100644 --- a/app/common/enum/OrderType.php +++ b/app/common/enum/OrderType.php @@ -40,6 +40,12 @@ class OrderType extends EnumBasics // 余额充值订单 const RECHARGE = 100; + //零售商城 + const RETAIL = 70; + + //批发商城 + const SALE = 80; + /** * 获取订单类型值 @@ -75,6 +81,14 @@ class OrderType extends EnumBasics self::WHOLESALER => [ 'name' => '开通采购商订单', 'value' => self::WHOLESALER, + ], + self::RETAIL => [ + 'name' => '开通零售商城订单', + 'value' => self::RETAIL, + ], + self::SALE => [ + 'name' => '开通采批发商城订单', + 'value' => self::SALE, ] ]; } diff --git a/app/common/enum/RetailDescribeEnum.php b/app/common/enum/RetailDescribeEnum.php index 191246e1..4bbf2ff2 100644 --- a/app/common/enum/RetailDescribeEnum.php +++ b/app/common/enum/RetailDescribeEnum.php @@ -18,6 +18,8 @@ class RetailDescribeEnum extends EnumBasics const MULTI_MERCHANT = 11; const CONTENT_MANAGEMENT = 12; const OTHER_FEATURES = 13; + const BUYER = 14; // 采购商 + const SERVICE_PROVIDER = 15; // 服务商 public static $version = [ self::GOODS => "商品", @@ -33,6 +35,8 @@ class RetailDescribeEnum extends EnumBasics self::MULTI_MERCHANT => "多商户", self::CONTENT_MANAGEMENT => "内容管理", self::OTHER_FEATURES => "其他功能", + self::BUYER => "采购商", + self::SERVICE_PROVIDER => "服务商" ]; private function __construct() { diff --git a/app/common/enum/user/balanceLog/Scene.php b/app/common/enum/user/balanceLog/Scene.php index a0bc8efb..8d6e9dbf 100644 --- a/app/common/enum/user/balanceLog/Scene.php +++ b/app/common/enum/user/balanceLog/Scene.php @@ -32,6 +32,9 @@ class Scene extends EnumBasics // 订单退款 const REFUND = 40; + + //购买商城 + const BUY_SHOP = 50; //开通分销商 const DEALER = 70; @@ -69,6 +72,11 @@ class Scene extends EnumBasics 'value' => self::REFUND, 'describe' => '订单退款:%s', ], + self::BUY_SHOP => [ + 'name' => '购买商城', + 'value' => self::BUY_SHOP, + 'describe' => '购买商城:%s', + ], self::DEALER => [ 'name' => '开通分销商', 'value' => self::DEALER,