|
@@ -769,18 +769,132 @@ class StoreOrder extends BaseModel
|
|
|
{
|
|
|
$order = self::where('order_id', $orderId)->find();
|
|
|
$resPink = true;
|
|
|
- $res1 = self::where('order_id', $orderId)->update(['paid' => 1, 'pay_type' => $paytype, 'pay_time' => time(), 'is_del' => 0, 'is_system_del' => 0, 'mark' => '']);
|
|
|
+ $res1 = self::where('order_id', $orderId)->update(['paid' => 1, 'pay_type' => $paytype, 'pay_time' => time(), 'is_del' => 0, 'is_system_del' => 0, 'mark' => '', 'status' => 2]);
|
|
|
if ($order->combination_id && $res1 && !$order->refund_status) $resPink = StorePink::createPink($order);
|
|
|
$oid = self::where('order_id', $orderId)->value('id');
|
|
|
StoreOrderStatus::status($oid, 'pay_success', '用户付款成功');
|
|
|
$now_money = User::where('uid', $order['uid'])->value('now_money');
|
|
|
UserBill::expend('购买商品', $order['uid'], 'now_money', 'pay_money', $order['pay_price'], $order['id'], $now_money, '支付' . floatval($order['pay_price']) . '元购买商品');
|
|
|
|
|
|
+ self::operation($order['uid'], $orderId);
|
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
|
$res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
|
|
|
return false !== $res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ * 发放优惠券
|
|
|
+ * @param $uid
|
|
|
+ * @param $orderId
|
|
|
+ * @return void
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ */
|
|
|
+ public static function operation($uid, $orderId)
|
|
|
+ {
|
|
|
+ $order = self::where('order_id', $orderId)->find();
|
|
|
+ $info = StoreOrderCartInfo::where('oid', $order['id'])->select();
|
|
|
+ $user = User::where('uid', $uid)->find();
|
|
|
+ foreach ($info as $v){
|
|
|
+ $product = StoreProduct::where('id', $v['product_id'])->find();
|
|
|
+ $cart_info = $v['cart_info'];
|
|
|
+ $coupon = StoreCoupon::where('id', 'in', $product['coupon'])->select();
|
|
|
+ if ($coupon){
|
|
|
+ for ($i = 0;$i < $cart_info['cart_num']; $i++){
|
|
|
+ foreach ($coupon as $value){
|
|
|
+ $data = [
|
|
|
+ 'cid' => $value['id'],
|
|
|
+ 'uid' => $uid,
|
|
|
+ 'coupon_title' => $value['title'],
|
|
|
+ 'coupon_price' => $value['coupon_price'],
|
|
|
+ 'use_min_price' => $value['use_min_price'],
|
|
|
+ 'add_time' => $value['start_time'] == 0? 0 : $value['start_time'],
|
|
|
+ 'end_time' => $value['end_time'] == 0? 0 : $value['end_time'],
|
|
|
+ 'code' => generate_promotion_code(1),
|
|
|
+ 'store_id' => $value['store_id'],
|
|
|
+ ];
|
|
|
+ StoreCouponUser::create($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($product['id'] == 1){
|
|
|
+
|
|
|
+ if ($user['spread_uid']) self::superior_push($user['spread_uid']);
|
|
|
+ if ($user['level'] < 2) $user['level'] = 2;
|
|
|
+ }else if ($product['id'] = 2){
|
|
|
+ if ($user['spread_uid']) self::superior($user['spread_uid']);
|
|
|
+ if ($user['level'] < 1) $user['level'] = 1;
|
|
|
+ }
|
|
|
+ $user->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 推广2999礼包奖励
|
|
|
+ * @param $uid
|
|
|
+ * @return void
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ */
|
|
|
+ public static function superior_push($uid)
|
|
|
+ {
|
|
|
+ $top1 = User::where('uid', $uid)->find();
|
|
|
+
|
|
|
+ $top2 = User::where('uid', $top1['spread_uid'])->find();
|
|
|
+ $top1['brokerage_price'] += 1200;
|
|
|
+ $top2['brokerage_price'] += 600;
|
|
|
+ if ($top1['level'] == 2){
|
|
|
+ $top1->save();
|
|
|
+ UserBill::income('佣金', $top1['uid'], 'now_money', 'brokerage', 1200, 0, $top1['brokerage_price'], '直推2999礼包奖励');
|
|
|
+ }
|
|
|
+ if ($top2['level'] == 2){
|
|
|
+ $top2->save();
|
|
|
+ UserBill::income('佣金', $top2['uid'], 'now_money', 'brokerage', 600, 0, $top2['brokerage_price'], '间推2999礼包奖励');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 推广399礼包奖励
|
|
|
+ * @param $uid
|
|
|
+ * @return void
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ */
|
|
|
+ public static function superior($uid)
|
|
|
+ {
|
|
|
+ $top1 = User::where('uid', $uid)->find();
|
|
|
+ $price = 0;
|
|
|
+ if ($top1['level'] == 1){
|
|
|
+ $top1['brokerage_price'] += 40;
|
|
|
+ $price = 40;
|
|
|
+
|
|
|
+ }elseif ($top1['level'] == 2){
|
|
|
+ $top1['brokerage_price'] += 130;
|
|
|
+ $price = 130;
|
|
|
+ }
|
|
|
+ if ($top1['spread_uid']){
|
|
|
+ $user = getParent($top1['uid']);
|
|
|
+ if ($user){
|
|
|
+ foreach ($user as $v){
|
|
|
+ $top = User::where('uid', $v)->find();
|
|
|
+ $top['brokerage_price'] += 90;
|
|
|
+ $top->save();
|
|
|
+ UserBill::income('佣金', $top1['uid'], 'now_money', 'brokerage', 90, 0, $top['brokerage_price'], '间推399礼包奖励');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $top1->save();
|
|
|
+ UserBill::income('佣金', $top1['uid'], 'now_money', 'brokerage', $price, 0, $top1['brokerage_price'], '直推399礼包奖励');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* 线下支付消息通知
|
|
|
* 待完善
|