|
|
@@ -429,6 +429,7 @@ class StoreOrder extends BaseModel
|
|
|
'deduction_price' => $deductionPrice,
|
|
|
'totalIntegral' => $payIntegral,
|
|
|
'SurplusIntegral' => $SurplusIntegral,
|
|
|
+ 'Purple_integral' => $payPrice * 1.01
|
|
|
];
|
|
|
}
|
|
|
$orderDate = StoreOrder::where('uid', $uid)->where('paid', 1)->where('pay_type', '<>', 'integral')->where('add_time', '>=', strtotime('2022-8-5 12:24:00'))->where('cumulative', '<', 2000)->where('use_integral', '=', 0)->find();
|
|
|
@@ -710,6 +711,42 @@ class StoreOrder extends BaseModel
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 余额支付
|
|
|
+ * @param $order_id
|
|
|
+ * @param $uid
|
|
|
+ * @param string $formId
|
|
|
+ * @return bool
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public static function purplePay($order_id, $uid, $formId = '')
|
|
|
+ {
|
|
|
+ $orderInfo = self::where('uid', $uid)->where('order_id', $order_id)->where('is_del', 0)->find();
|
|
|
+ if (!$orderInfo) return self::setErrorInfo('订单不存在!');
|
|
|
+// if ($orderInfo['paid']) return self::setErrorInfo('该订单已支付!');
|
|
|
+// if($orderInfo['pay_type'] != 'yue') return self::setErrorInfo('该订单不能使用余额支付!');
|
|
|
+ $userInfo = User::getUserInfo($uid);
|
|
|
+ $orderInfo['pay_price'] = $orderInfo['pay_price'] * 1.01;
|
|
|
+ if ($userInfo['purple_integral'] < $orderInfo['pay_price'])
|
|
|
+ return self::setErrorInfo(['status' => 'pay_deficiency', 'msg' => '阳光积分不足' . floatval($orderInfo['pay_price'])]);
|
|
|
+ self::beginTrans();
|
|
|
+
|
|
|
+ $res1 = false !== User::bcDec($uid, 'purple_integral', $orderInfo['pay_price'], 'uid');
|
|
|
+ $res3 = self::paySuccess($order_id, 'purple', $formId);//余额支付成功
|
|
|
+ try {
|
|
|
+ PaymentRepositories::yuePayProduct($userInfo, $orderInfo);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ self::rollbackTrans();
|
|
|
+ return self::setErrorInfo($e->getMessage());
|
|
|
+ }
|
|
|
+ $res = $res1 && $res3;
|
|
|
+ self::checkTrans($res);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 微信支付 为 0元时
|
|
|
* @param $order_id
|
|
|
@@ -866,7 +903,14 @@ class StoreOrder extends BaseModel
|
|
|
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']) . '元购买商品');
|
|
|
+ if ($paytype == 'purple'){
|
|
|
+ $order['pay_price'] = $order['pay_price'] * 1.01;
|
|
|
+ $order->save();
|
|
|
+ $purple_integral = User::where('uid', $order['uid'])->value('purple_integral');
|
|
|
+ UserBill::expend('购买商品', $order['uid'], 'purple_integral', 'pay_product', $order['pay_price'], $order['id'], $purple_integral, '阳光积分支付' . floatval($order['pay_price']) . '元购买商品');
|
|
|
+ }else{
|
|
|
+ UserBill::expend('购买商品', $order['uid'], 'now_money', 'pay_money', $order['pay_price'], $order['id'], $now_money, '支付' . floatval($order['pay_price']) . '元购买商品');
|
|
|
+ }
|
|
|
//支付成功后
|
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
|
$res3 = StoreOrder::gainWhiteIntegral($order);
|