计算爆单商品

main
home.fengxinyhyl 8 months ago
parent 513e4cded9
commit 778d7638e7
  1. 27
      app/common/dao/store/order/StoreOrderHotDao.php
  2. 61
      app/common/model/store/StoreOrderHot.php
  3. 39
      app/common/repositories/store/order/StoreOrderHotRepository.php
  4. 2
      app/common/repositories/store/product/ProductRepository.php
  5. 40
      app/common/repositories/user/UserAssetsLogRepository.php
  6. 18
      app/controller/api/Auth.php
  7. 1
      app/event.php
  8. 2
      config/swoole.php
  9. 32
      crmeb/listens/pay/CustomizeTake.php

@ -0,0 +1,27 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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;
}
}

@ -0,0 +1,61 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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);
}
}

@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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);
}
}

@ -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',

@ -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);
}

@ -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();
}

@ -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' => [],

@ -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' => [

@ -0,0 +1,32 @@
<?php
/**
* CustomizePaySuccess.php
* 文件描述
* Created on 2024/3/13 23:02
* Created by zhangkaixiang
*/
namespace crmeb\listens\pay;
use app\common\repositories\user\UserAssetsLogRepository;
use crmeb\interfaces\ListenerInterface;
use think\facade\Log;
class CustomizeTake implements ListenerInterface
{
// {"order":{"order_id":33,"main_id":0,"group_order_id":32,"order_sn":"wxo1710768193328392661","uid":3,"spread_uid":0,"top_uid":1,"district_id":3378,"real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","cart_id":"77","total_num":1,"total_price":"100.00","total_postage":"0.00","pay_price":"100.00","pay_postage":"0.00","is_selfbuy":0,"extension_one":"0.00","extension_two":"1.20","commission_rate":"30.0000","integral":0,"integral_price":"0.00","give_integral":100,"coupon_id":"","coupon_price":"0.00","platform_coupon_price":"0.00","svip_discount":"0.00","order_type":0,"paid":1,"pay_time":"2024-03-18 21:23:13","pay_type":0,"create_time":"2024-03-18 21:23:13","status":2,"delivery_type":"1","is_virtual":0,"delivery_name":"\u97f5\u8fbe\u5feb\u9012","delivery_id":"ewrwe","mark":"","remark":"","admin_mark":null,"verify_code":null,"verify_time":"2024-03-19 14:43:24","verify_service_id":null,"transaction_id":null,"activity_type":0,"order_extend":null,"mer_id":6,"reconciliation_id":0,"cost":"0.00","is_del":0,"is_system_del":0,"verify_status":0,"presellOrder":null}}
public function handle($data): void
{
Log::info('收货' . json_encode($data));
if(isset($data['order']) and $data['order']){
/**
* @var UserAssetsLogRepository $repository
*/
$repository = app()->make(UserAssetsLogRepository::class);
$repository->userTakeEvent($data['order']);
}
}
}
Loading…
Cancel
Save