| xqd
@@ -118,21 +118,21 @@ class SpecialBuy extends ModelBasic
|
|
|
public static function PaySpecial($special_id, $uid)
|
|
|
{
|
|
|
self::where(['uid' => $uid, 'special_id' => $special_id, 'is_del' => 0])->where('validity_time', ['>', 0], ['<', time()], 'and')->update(['is_del' => 1]);
|
|
|
- $flag = self::where(['uid' => $uid, 'special_id' => $special_id, 'is_del' => 0])->count() ? true : false;
|
|
|
+ $buyinfo = self::where(['uid' => $uid, 'special_id' => $special_id, 'is_del' => 0])->find();
|
|
|
+ $flag = $buyinfo ? true : false;
|
|
|
if (!$flag) {
|
|
|
$join = [
|
|
|
['PlanBuy pb', "pb.planid = pt.pid and pb.uid=" . $uid, 'inner']
|
|
|
];
|
|
|
- $planItems = PlanItems::alias('pt')->join($join)->where(['pt.cid'=>$special_id])->count();
|
|
|
+ $planItems = PlanItems::alias('pt')->join($join)->where(['pt.cid'=>$special_id])->find();
|
|
|
$flag = $planItems ? true : false;
|
|
|
if ($flag) {
|
|
|
//将课程信息插入到specialbuy里面
|
|
|
- $spinfo = Special::where(['id' => $special_id])->find();
|
|
|
- $planItems = PlanItems::alias('pt')->join($join)->where(['pt.cid'=>$special_id])->find()->toArray();
|
|
|
SpecialBuy::setBuySpecial($planItems['orderid'], $uid, $special_id, $planItems['type'], 0, 0, $planItems['pid']);
|
|
|
TestPaperObtain::setTestPaper($planItems['orderid'], $uid, $special_id, 2, $planItems['pid']);
|
|
|
}
|
|
|
-
|
|
|
+ } else {
|
|
|
+ TestPaperObtain::setTestPaper($buyinfo['order_id'], $uid, $special_id, 2, 0);
|
|
|
}
|
|
|
return $flag;
|
|
|
}
|