订单贡献值格式调整

main
limu 12 months ago
parent c4a78b46c8
commit 38be24aaa2
  1. 3
      app/common/repositories/store/order/StoreOrderCreateRepository.php
  2. 2
      app/common/repositories/store/order/StoreOrderRepository.php
  3. 11
      crmeb/jobs/OrderPartnerJob.php

@ -1058,6 +1058,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$rate = bcmul($merchantCart['merchantCategory']['commission_rate'], 100, 4); $rate = bcmul($merchantCart['merchantCategory']['commission_rate'], 100, 4);
} }
$user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : ''; $user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : '';
//整理订单数据 //整理订单数据
$_order = [ $_order = [
'cartInfo' => $merchantCart, 'cartInfo' => $merchantCart,
@ -1093,7 +1094,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2), 'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2),
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'], 'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
'pay_type' => $pay_type, 'pay_type' => $pay_type,
'user_address_id' => $user_address['address_id'] ?? 0, 'user_address_id' => $address['address_id'] ?? 0,
]; ];
$allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']); $allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']);
$orderList[] = $_order; $orderList[] = $_order;

@ -745,7 +745,7 @@ class StoreOrderRepository extends BaseRepository
$storeOrderStatusRepository->{$func}($orderStatus); $storeOrderStatusRepository->{$func}($orderStatus);
}); });
//推送到贡献值结算队列 //推送到贡献值结算队列
Queue::push(OrderPartnerJob::class, compact('order')); Queue::push(OrderPartnerJob::class, $order->toArray());
event('order.take', compact('order')); event('order.take', compact('order'));

@ -32,8 +32,9 @@ use app\common\repositories\user\UserAddressRepository;
class OrderPartnerJob implements JobInterface class OrderPartnerJob implements JobInterface
{ {
public function fire($job,$data) public function fire($job, $data)
{ {
file_put_contents('/tmp/debug_partner', '开始处理贡献值订单:'.var_export($data, 1), 8);
try { try {
//初始化贡献值 //初始化贡献值
$bao_price = $mian_price = $ping_price = $total_price = 0; $bao_price = $mian_price = $ping_price = $total_price = 0;
@ -201,7 +202,7 @@ class OrderPartnerJob implements JobInterface
->select()->toArray(); ->select()->toArray();
$role_ids = array_column($trade_roles, 'id'); $role_ids = array_column($trade_roles, 'id');
$trade_trade_data = array_column($trade_roles,null, 'id'); $trade_trade_data = array_column($trade_roles, null, 'id');
$user_list = User::getDB()->alias('u') $user_list = User::getDB()->alias('u')
->leftJoin('UserPartner p', 'u.uid = p.uid') ->leftJoin('UserPartner p', 'u.uid = p.uid')
->whereIn('p.partner_id', $role_ids) ->whereIn('p.partner_id', $role_ids)
@ -245,7 +246,7 @@ class OrderPartnerJob implements JobInterface
->select()->toArray(); ->select()->toArray();
$role_ids = array_column($area_roles, 'id'); $role_ids = array_column($area_roles, 'id');
$trade_trade_data = array_column($area_roles, null,'id'); $trade_trade_data = array_column($area_roles, null, 'id');
$user_list = User::getDB()->alias('u') $user_list = User::getDB()->alias('u')
->leftJoin('UserPartner p', 'u.uid = p.uid') ->leftJoin('UserPartner p', 'u.uid = p.uid')
->whereIn('p.partner_id', $role_ids) ->whereIn('p.partner_id', $role_ids)
@ -280,7 +281,7 @@ class OrderPartnerJob implements JobInterface
->where('status', 1) ->where('status', 1)
->select()->toArray(); ->select()->toArray();
$role_ids = array_column($common_roles, 'id'); $role_ids = array_column($common_roles, 'id');
$common_trade_data = array_column($common_roles, null,'id'); $common_trade_data = array_column($common_roles, null, 'id');
$user_list = User::getDB()->alias('u') $user_list = User::getDB()->alias('u')
->leftJoin('UserPartner p', 'u.uid = p.uid') ->leftJoin('UserPartner p', 'u.uid = p.uid')
->field('u.*,p.partner_id') ->field('u.*,p.partner_id')
@ -288,7 +289,7 @@ class OrderPartnerJob implements JobInterface
->where('u.uid', '<>', $data['uid']) ->where('u.uid', '<>', $data['uid'])
->select(); ->select();
if(!empty($user_list)){ if (!empty($user_list)) {
$user_list = $user_list->toArray(); $user_list = $user_list->toArray();
$user_count = count($user_list); $user_count = count($user_list);
foreach ($user_list as $cuk => $cuv) { foreach ($user_list as $cuk => $cuv) {

Loading…
Cancel
Save