|
@@ -231,7 +231,7 @@ class DiagnosisOrder extends BaseModel
|
|
|
if (!$order)return self::setErrorInfo('订单不存在!');
|
|
|
if ($order['paid'] == 1) return self::setErrorInfo('订单已支付!');
|
|
|
if ($order['user_card_id']){
|
|
|
- self::card($order['user_card_id'], $order['cate_id']);
|
|
|
+ self::card($order['user_card_id'], $order['cate_id'], $order['uid']);
|
|
|
}
|
|
|
|
|
|
self::where('order_id', $orderId)->update(['paid' => 1, 'pay_time' => time()]);
|
|
@@ -249,12 +249,21 @@ class DiagnosisOrder extends BaseModel
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public static function card($card_id, $c_id)
|
|
|
+ public static function card($card_id, $c_id, $uid)
|
|
|
{
|
|
|
+ $c_id = explode(',', $c_id);
|
|
|
+ $equity = [];
|
|
|
+ foreach ($c_id as $item){
|
|
|
+ $id = UserEquity::where('user_card_id', 'in', $card_id)->where('uid', $uid)->where('c_id', 'like', '%'.$item.'%')->value('id');
|
|
|
+ if ($id){
|
|
|
+ $equity[] = $id;
|
|
|
+ }
|
|
|
|
|
|
- $equity = UserEquity::where('user_card_id', 'in', $card_id)->where('c_id', 'like', '%'.$c_id.'%')->select();
|
|
|
- if ($equity){
|
|
|
- foreach ($equity as $item){
|
|
|
+ }
|
|
|
+ $equity = array_unique($equity);
|
|
|
+ $equitys = UserEquity::where('id', 'in', $equity)->select();
|
|
|
+ if ($equitys){
|
|
|
+ foreach ($equitys as $item){
|
|
|
if ($item['type'] == 2){
|
|
|
if ($item['number'] == 1){
|
|
|
UserEquity::where('id', $item['id'])->update(['use' => 0]);
|