From 778d7638e75a60ce535ba3c8eea6dfa1832eff86 Mon Sep 17 00:00:00 2001 From: "home.fengxinyhyl" Date: Mon, 8 Apr 2024 22:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=88=86=E5=8D=95=E5=95=86?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/order/StoreOrderHotDao.php | 27 ++++++++ app/common/model/store/StoreOrderHot.php | 61 +++++++++++++++++++ .../store/order/StoreOrderHotRepository.php | 39 ++++++++++++ .../store/product/ProductRepository.php | 2 +- .../user/UserAssetsLogRepository.php | 40 +++++++++--- app/controller/api/Auth.php | 18 +----- app/event.php | 1 + config/swoole.php | 2 +- crmeb/listens/pay/CustomizeTake.php | 32 ++++++++++ 9 files changed, 197 insertions(+), 25 deletions(-) create mode 100644 app/common/dao/store/order/StoreOrderHotDao.php create mode 100644 app/common/model/store/StoreOrderHot.php create mode 100644 app/common/repositories/store/order/StoreOrderHotRepository.php create mode 100644 crmeb/listens/pay/CustomizeTake.php diff --git a/app/common/dao/store/order/StoreOrderHotDao.php b/app/common/dao/store/order/StoreOrderHotDao.php new file mode 100644 index 0000000..d75f67e --- /dev/null +++ b/app/common/dao/store/order/StoreOrderHotDao.php @@ -0,0 +1,27 @@ + +// +---------------------------------------------------------------------- + +namespace app\common\dao\store\order; + +use app\common\dao\BaseDao; +use app\common\model\store\order\StoreOrderReceipt; +use app\common\model\store\StoreOrderHot; +use app\common\model\user\User; + +class StoreOrderHotDao extends BaseDao +{ + protected function getModel(): string + { + return StoreOrderHot::class; + } + +} diff --git a/app/common/model/store/StoreOrderHot.php b/app/common/model/store/StoreOrderHot.php new file mode 100644 index 0000000..635d061 --- /dev/null +++ b/app/common/model/store/StoreOrderHot.php @@ -0,0 +1,61 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\store; + + +use app\common\model\BaseModel; +use app\common\model\store\order\StoreOrder; +use app\common\model\store\product\Product; +use app\common\model\store\product\Spu; +use app\common\model\user\User; + +class StoreOrderHot extends BaseModel +{ + + public static function tablePk(): ?string + { + return 'id'; + } + + public static function tableName(): string + { + return 'store_order_hot'; + } + + public function orderInfo() + { + return $this->hasOne(StoreOrder::class, 'order_id', 'order_id'); + } + + public function user() + { + return $this->hasOne(User::class,'uid','uid'); + } + + public function product() + { + return $this->hasOne(Product::class,'product_id','product_id'); + } + + public function spu() + { + return $this->hasOne(Spu::class,'product_id','product_id'); + } + + public function searchUidAttr($query ,$value) + { + $query->where('uid',$value); + } + +} diff --git a/app/common/repositories/store/order/StoreOrderHotRepository.php b/app/common/repositories/store/order/StoreOrderHotRepository.php new file mode 100644 index 0000000..93098ac --- /dev/null +++ b/app/common/repositories/store/order/StoreOrderHotRepository.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\store\order; + + +use app\common\dao\store\order\StoreOrderHotDao; +use app\common\repositories\BaseRepository; + +/** + * @mixin StoreOrderHotDao + */ +class StoreOrderHotRepository extends BaseRepository +{ + + /** + * @var StoreOrderHotDao + */ + protected $dao; + + public function __construct(StoreOrderHotDao $storeOrderHotDao) + { + $this->dao = $storeOrderHotDao; + } + + public function create($data){ + $this->dao->create($data); + } + +} diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 75ff984..c40d2ed 100755 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -1325,7 +1325,7 @@ class ProductRepository extends BaseRepository public function apiProductDetail($where, int $productType, ?int $activityId, $userInfo = null) { - $field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status,mer_form_id'; + $field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,is_hot,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status,mer_form_id,normal_intergal_one,normal_intergal_two,normal_diamond_one,normal_diamond_two,hot_intergal_one,hot_intergal_two,hot_diamond_one,hot_diamond_two,hot_intergal_rate,hot_intergal_total'; $with = [ 'attr', 'attrValue', diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index f7b22c4..70874ab 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -15,6 +15,8 @@ namespace app\common\repositories\user; use app\common\dao\user\UserAssetsLogDao; use app\common\repositories\BaseRepository; +use app\common\repositories\store\order\StoreOrderHotRepository; +use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\store\product\ProductRepository; use app\common\repositories\system\groupData\GroupDataRepository; use think\db\exception\DataNotFoundException; @@ -52,7 +54,13 @@ class UserAssetsLogRepository extends BaseRepository public function __construct(UserAssetsLogDao $dao, UserAssetsRepository $userAssetsRepository, ProductRepository $productRepository, GroupDataRepository $groupRepository) { $this->dao = $dao; + /** + * @var UserAssetsRepository + */ $this->userAssetsRepository = $userAssetsRepository; + /** + * @var ProductRepository + */ $this->productRepository = $productRepository; $this->groupDataRepository = $groupRepository; } @@ -118,16 +126,34 @@ class UserAssetsLogRepository extends BaseRepository */ public function userTakeEvent($orderItem) { - // 订单发送冻结资产发放 - $refundList = $this->_getOrderData($orderItem['order_id'], self::STATUS_FROZEN); - if ($refundList) { - foreach ($refundList as $refund) { - $this->userAssetsRepository->orderEvent($refund['uid'], self::STATUS_SUCCESS, $refund); + /** + * @var StoreOrderRepository $orderRepository + */ + $orderRepository = app(StoreOrderRepository::class); + + /** + * @var StoreOrderHotRepository + */ + $hotRepository = app(StoreOrderHotRepository::class); + + + $order = $orderRepository->getDetail($orderItem['order_id']); +// Log::info("order is".json_encode($order)); + + foreach ($order['orderProduct'] as $productItem){ + $product = $this->productRepository->get($productItem['product_id']); + Log::info("product is". json_encode($product)); + if($product['is_hot']){ + $hotData = array( + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'product_id' => $productItem['product_id'], + 'create_time' => date('Y-m-d H:i:s') + ); + $hotRepository->create($hotData); } } - // 更新该订单的所有数据为退款状态 - $this->dao->updateOrderStatus($orderItem['order_id'], self::STATUS_SUCCESS); } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 6f67246..be8c89a 100755 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -56,22 +56,8 @@ class Auth extends BaseController { public function test() { -// $data = [ -// 'tempId' => '', -// 'id' => '', -// ]; -// Queue::push(SendSmsJob::class,$data); -// $status = app()->make(SystemNoticeConfigRepository::class)->getNoticeStatusByConstKey($data['tempId']); -// if ($status['notice_sms'] == 1) { -// SmsService::sendMessage($data); -// } -// if ($status['notice_wechat'] == 1) { -// app()->make(WechatTemplateMessageService::class)->sendTemplate($data); -// } -// if ($status['notice_routine'] == 1) { -// app()->make(WechatTemplateMessageService::class)->subscribeSendTemplate($data); -// } - Log::info("aaaaa"); + event('order.take', array('order' => array('order_id' => 1))); + return app('json')->success(); } diff --git a/app/event.php b/app/event.php index 2933a2c..9d9ac9b 100755 --- a/app/event.php +++ b/app/event.php @@ -67,6 +67,7 @@ return [ //操作日志 'create_operate_log' => [\crmeb\listens\CreateOperateLogListen::class], // 操作日志事件 'mini_order_shipping' => [\crmeb\listens\MiniOrderShippingListen::class], // 小程序发货管理事件 + 'order.take' => [\crmeb\listens\pay\CustomizeTake::class], ], 'subscribe' => [], diff --git a/config/swoole.php b/config/swoole.php index 232b307..87b1699 100755 --- a/config/swoole.php +++ b/config/swoole.php @@ -17,7 +17,7 @@ use think\swoole\websocket\socketio\Parser; return [ 'server' => [ 'host' => env('SWOOLE_HOST', '0.0.0.0'), // 监听地址 - 'port' => env('SWOOLE_PORT', 8324), // 监听端口 + 'port' => env('SWOOLE_PORT', 8325), // 监听端口 'mode' => SWOOLE_PROCESS, // 运行模式 默认为SWOOLE_PROCESS 'sock_type' => SWOOLE_SOCK_TCP, // sock type 默认为SWOOLE_SOCK_TCP 'options' => [ diff --git a/crmeb/listens/pay/CustomizeTake.php b/crmeb/listens/pay/CustomizeTake.php new file mode 100644 index 0000000..7a1a307 --- /dev/null +++ b/crmeb/listens/pay/CustomizeTake.php @@ -0,0 +1,32 @@ +make(UserAssetsLogRepository::class); + $repository->userTakeEvent($data['order']); + } + } +}