|
@@ -18,7 +18,7 @@ use crmeb\traits\ModelTrait;
|
|
|
use think\facade\Log;
|
|
use think\facade\Log;
|
|
|
use app\models\system\SystemStore;
|
|
use app\models\system\SystemStore;
|
|
|
use app\models\routine\RoutineTemplate;
|
|
use app\models\routine\RoutineTemplate;
|
|
|
-use app\models\user\{User, UserAddress, UserBill, UserSpread, WechatUser};
|
|
|
|
|
|
|
+use app\models\user\{User, UserAddress, UserBill, UserSingleAward, UserSpread, WechatUser};
|
|
|
use crmeb\services\{
|
|
use crmeb\services\{
|
|
|
SystemConfigService, WechatTemplateService, workerman\ChannelService
|
|
SystemConfigService, WechatTemplateService, workerman\ChannelService
|
|
|
};
|
|
};
|
|
@@ -316,7 +316,10 @@ class StoreOrder extends BaseModel
|
|
|
$cartIds = [];
|
|
$cartIds = [];
|
|
|
$totalNum = 0;
|
|
$totalNum = 0;
|
|
|
$gainIntegral = 0;
|
|
$gainIntegral = 0;
|
|
|
|
|
+ $is_explosion_order = 0;
|
|
|
foreach ($cartInfo as $cart) {
|
|
foreach ($cartInfo as $cart) {
|
|
|
|
|
+ $product = StoreProduct::where('id', $cart['product_id'])->find();
|
|
|
|
|
+ if (strstr(2,$product['cate_id'])) $is_explosion_order = 1;
|
|
|
$cartIds[] = $cart['id'];
|
|
$cartIds[] = $cart['id'];
|
|
|
$totalNum += $cart['cart_num'];
|
|
$totalNum += $cart['cart_num'];
|
|
|
if (!$seckill_id) $seckill_id = $cart['seckill_id'];
|
|
if (!$seckill_id) $seckill_id = $cart['seckill_id'];
|
|
@@ -450,6 +453,7 @@ class StoreOrder extends BaseModel
|
|
|
'add_time' => time(),
|
|
'add_time' => time(),
|
|
|
'unique' => $key,
|
|
'unique' => $key,
|
|
|
'shipping_type' => $shipping_type,
|
|
'shipping_type' => $shipping_type,
|
|
|
|
|
+ 'is_explosion_order' => $is_explosion_order,
|
|
|
];
|
|
];
|
|
|
if ($shipping_type === 2) {
|
|
if ($shipping_type === 2) {
|
|
|
$orderInfo['verify_code'] = self::getStoreCode();
|
|
$orderInfo['verify_code'] = self::getStoreCode();
|
|
@@ -777,10 +781,70 @@ class StoreOrder extends BaseModel
|
|
|
UserBill::expend('购买商品', $order['uid'], 'now_money', 'pay_money', $order['pay_price'], $order['id'], $now_money, '支付' . floatval($order['pay_price']) . '元购买商品');
|
|
UserBill::expend('购买商品', $order['uid'], 'now_money', 'pay_money', $order['pay_price'], $order['id'], $now_money, '支付' . floatval($order['pay_price']) . '元购买商品');
|
|
|
//支付成功后
|
|
//支付成功后
|
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
|
|
|
+ if ($order['is_explosion_order'] == 1){
|
|
|
|
|
+ self::push($order);
|
|
|
|
|
+ self::award($order);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
|
|
$res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
|
|
|
return false !== $res;
|
|
return false !== $res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 直推奖励
|
|
|
|
|
+ * @param $order
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function push($order)
|
|
|
|
|
+ {
|
|
|
|
|
+ $user = User::where('uid', $order['uid'])->find();
|
|
|
|
|
+ if ($user['spread_uid']){
|
|
|
|
|
+ $spread = User::where('uid', $user['spread_uid'])->where('level', '>=', 1)->find();
|
|
|
|
|
+ if ($spread){
|
|
|
|
|
+ $model = new UserSingleAward();
|
|
|
|
|
+ $award = $model->where('uid', $spread['uid'])->where('status', 0)->select()->toArray();
|
|
|
|
|
+ if ($award){
|
|
|
|
|
+ $group_purchase = sys_config('push');
|
|
|
|
|
+ $jl = round($order['pay_price'] * ($group_purchase/100), 2); // 应奖励金额
|
|
|
|
|
+ $bdjl = 0; // 爆单剩余奖励
|
|
|
|
|
+ foreach ($award as &$item){
|
|
|
|
|
+ $surplus = $item['money'] - $item['grant'];
|
|
|
|
|
+ if ($surplus < $jl){
|
|
|
|
|
+ $bdjl += $surplus;
|
|
|
|
|
+ $jl -= $surplus;
|
|
|
|
|
+ $item['status'] = 1;
|
|
|
|
|
+ $item['grant'] = $item['money'];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $bdjl += $jl;
|
|
|
|
|
+ $item['grant'] += $jl;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $model->saveAll($award);
|
|
|
|
|
+
|
|
|
|
|
+ UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $bdjl, '', $spread['brokerage_price']+$bdjl, '分享佣金奖励');
|
|
|
|
|
+ User::where('uid', $spread['uid'])->inc('brokerage_price', $bdjl)->update();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 添加单奖记录
|
|
|
|
|
+ * @param $order
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function award($order)
|
|
|
|
|
+ {
|
|
|
|
|
+ $money = $order['total_num'] * 10000;
|
|
|
|
|
+
|
|
|
|
|
+ UserSingleAward::create([
|
|
|
|
|
+ 'uid' => $order['uid'],
|
|
|
|
|
+ 'order_id' => $order['order_id'],
|
|
|
|
|
+ 'money' => $money,
|
|
|
|
|
+ 'create_time' => time(),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* 线下支付消息通知
|
|
* 线下支付消息通知
|
|
|
* 待完善
|
|
* 待完善
|