|
@@ -855,6 +855,7 @@ class StoreOrder extends BaseModel
|
|
|
$res2 = $res2 && self::addSuit($order);
|
|
|
$res2 = $res2 && StoreOrder::sendSuit($order);
|
|
|
$res2 = $res2 && StoreOrder::sendGroupAward($order);
|
|
|
+ $res2 = $res2 && StoreOrder::sendAllSystemAward($order);
|
|
|
$res2 = $res2 && SystemGroupLevel::checkLevel($order['uid']);
|
|
|
$res2 = $res2 && SystemAwardLevel::checkLevel($order['uid']);
|
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
@@ -2618,6 +2619,49 @@ class StoreOrder extends BaseModel
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
+ public static function sendAllSystemAward($order): bool
|
|
|
+ {
|
|
|
+// return true;
|
|
|
+ //TODO 营销产品不返佣金
|
|
|
+ if (isset($order['combination_id']) && $order['combination_id']) return true;
|
|
|
+ if (isset($order['seckill_id']) && $order['seckill_id']) return true;
|
|
|
+ if (isset($order['bargain_id']) && $order['bargain_id']) return true;
|
|
|
+
|
|
|
+ $userInfo = User::getUserInfo($order['uid']);
|
|
|
+
|
|
|
+ $cartInfo = StoreOrderCartInfo::whereIn('cart_id', $order['cart_id'])->column('cart_info');
|
|
|
+ $suit = 0;
|
|
|
+ $suit_price = 0;
|
|
|
+ foreach ($cartInfo as $value) {
|
|
|
+ $product = json_decode($value, true);
|
|
|
+ if (isset($product['productInfo'])) {
|
|
|
+ $productInfo = $product['productInfo'];
|
|
|
+ if ($product['is_suit']) {
|
|
|
+ $suit += $product['cart_num'] ?? 0;
|
|
|
+ $suit_price += ($productInfo['attrInfo']['price'] ?? $product['price']) * $product['cart_num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $levels = SystemGroupLevel::where('system_award', 1)->column('id');
|
|
|
+ $levels2 = SystemAwardLevel::where('system_award', 1)->column('id');
|
|
|
+
|
|
|
+ $users = User::where('group_level', 'in', $levels)->whereOr('award_level', 'in', $levels2)
|
|
|
+ ->select();
|
|
|
+ $res = true;
|
|
|
+
|
|
|
+ $award = bcdiv(bcmul(100, $suit, 2), count($users), 2);
|
|
|
+
|
|
|
+ if ($suit && $award) {
|
|
|
+ foreach ($users as $v) {
|
|
|
+ $mark = '用户' . $userInfo['nickname'] . '(' . $order['uid'] . ')' . '购买套装商品,获得董事分红' . $award;
|
|
|
+ $res = $res && UserBill::income('董事加权分红', $v['uid'], 'now_money', 'brokerage', $award, $order['id'], bcadd($v['brokerage_price'], $award, 2), $mark);
|
|
|
+ $res = $res && User::where('uid', $v['uid'])->inc('brokerage_price', $award)->update();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
public static function sendSuit($order): bool
|
|
|
{
|
|
|
// return true;
|