|
|
@@ -21,7 +21,7 @@ use think\facade\Log;
|
|
|
use app\models\system\SystemStore;
|
|
|
use app\models\routine\RoutineTemplate;
|
|
|
use think\Model;
|
|
|
-use app\models\user\{User, UserAddress, UserBill, UserSpread, WechatUser};
|
|
|
+use app\models\user\{User, UserAddress, UserBill, UserSpread, UserStorePromoter, WechatUser};
|
|
|
use crmeb\services\{MiniProgramService,
|
|
|
OtherSMSService,
|
|
|
SystemConfigService,
|
|
|
@@ -900,7 +900,7 @@ class StoreOrder extends BaseModel
|
|
|
//支付成功后
|
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
|
|
|
|
- $res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
|
|
|
+ $res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order) && self::promoteAward($order);
|
|
|
$user = User::getUserInfo($order['uid']);
|
|
|
if (!$order['store_order']) {
|
|
|
if ($user['phone'])
|
|
|
@@ -918,6 +918,31 @@ class StoreOrder extends BaseModel
|
|
|
return false !== $res;
|
|
|
}
|
|
|
|
|
|
+ public static function promoteAward($orderInfo)
|
|
|
+ {
|
|
|
+ if (isset($orderInfo['combination_id']) && $orderInfo['combination_id']) return true;
|
|
|
+ if (isset($orderInfo['seckill_id']) && $orderInfo['seckill_id']) return true;
|
|
|
+ if (isset($orderInfo['bargain_id']) && $orderInfo['bargain_id']) return true;
|
|
|
+ if (isset($orderInfo['integral_id']) && $orderInfo['integral_id']) return true;
|
|
|
+ if (isset($orderInfo['exchange_id']) && $orderInfo['exchange_id']) return true;
|
|
|
+ if (!($orderInfo['store_id']) || !$orderInfo['store_id']) return true;
|
|
|
+ $userInfo = User::getUserInfo($orderInfo['uid']);
|
|
|
+ $store_Info = SystemStore::get($orderInfo['store_id']);
|
|
|
+ $promoters = UserStorePromoter::where('store_id', $orderInfo['store_id'])->select();
|
|
|
+ $res = true;
|
|
|
+ foreach ($promoters as $v) {
|
|
|
+ $award = bcmul(bcdiv($v['ratio'], 100, 4), bcsub($orderInfo['pay_price'], bcadd($orderInfo['pay_postage'], bcadd($orderInfo['deposit'], $orderInfo['pay_postage_sh'], 2), 2), 2), 2);
|
|
|
+ if ($award > 0) {
|
|
|
+ $spreadUserInfo = User::getUserInfo($v['uid']);
|
|
|
+ //TODO 上级推广员返佣之后的金额
|
|
|
+ $mark = $userInfo['nickname'] . '于门店' . $store_Info['name'] . '成功消费' . floatval($orderInfo['pay_price']) . '元,奖励佣金' . floatval($award);
|
|
|
+ //TODO 添加推广记录
|
|
|
+ $res = $res && UserBill::income('获得门店推广佣金', $v['uid'], 'now_money', 'brokerage', $award, $orderInfo['id'], $spreadUserInfo['brokerage_price'], $mark, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* 线下支付消息通知
|
|
|
* 待完善
|