You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

<?php
namespace app\common;
use think\facade\Db;
class SlashCard
{
public static function updateUser($order)
{
//判斷是否為SlashCard商品
$is_main = Db::name('order_goods')
->where('order_id', $order['order_id'])
->where('goods_id', 1)
->find();
if ($is_main) {
$params = [
'order_sn' => $order['order_sn'],
'user_id' => Db::name('users')->where('user_id', $order['user_id'])->value('sso_user_id'),
];
$rtn = \app\service\Card::addUser($params);
if ($rtn['code'] != 200) {
return ['code' => $rtn['code'], 'msg' => '更新slashcard失敗'];
}
return $rtn;
}else{
return ['code' => 201, 'msg' => '訂單無slashcard商品'];
}
}
public static function cancelUser($order)
{
//判斷是否為SlashCard商品
$is_main = Db::name('order_goods')
->where('order_id', $order['order_id'])
->where('goods_id', 1)
->find();
if ($is_main){
$params = [
'order_sn' => $order['order_sn'],
'user_id' => Db::name('users')->where('user_id', $order['user_id'])->value('sso_user_id'),
];
$rtn = \app\service\Card::cancelUser($params);
if ($rtn['code'] != 200 && $rtn['code'] != 201) {
return ['code' => $rtn['code'], 'msg' => '更新slashcard失敗'];
}
return $rtn;
}else{
return ['code' => 201, 'msg' => '訂單無slashcard商品'];
}
}
}