问题说明:用户下单时专题订单购买方法有误
修改文件:application/wap/model/store/StoreOrder.php
修改方法:createSpecialOrder()
/**
* 创建订单专题订单
* @param $special
* @param $pinkId
* @param $pay_type
* @param $uid
* @param $payType
* @param int $link_pay_uid
* @param int $total_num
* @return bool|object
*/
public static function createSpecialOrder($special, $pinkId, $pay_type, $uid, $payType, $link_pay_uid = 0, $total_num = 1)
{
if (!array_key_exists($payType, self::$payType)) return self::setErrorInfo('选择支付方式有误!');
$userInfo = User::getUserData($uid);
if (!$userInfo) return self::setErrorInfo('用户不存在!');
$total_price = 0;
$combination_id = 0;
switch ((int)$pay_type) {
case 1:
//送朋友
$total_price = $special->money;
if (isset($userInfo['level']) && $userInfo['level'] > 0 && $special->member_pay_type == 1 && $special->member_money > 0) {
$total_price = $special->member_money;
} else if (isset($userInfo['level']) && $userInfo['level'] > 0 && $special->member_pay_type == 0) {
return self::setErrorInfo('会员免费,该专题您不需要支付!');
}
break;
case 2:
//自己买
$total_price = $special->money;
if (isset($userInfo['level']) && $userInfo['level'] > 0 && $special->member_pay_type == 1 && $special->member_money > 0) {
$total_price = $special->member_money;
} else if (isset($userInfo['level']) && $userInfo['level'] > 0 && $special->member_pay_type == 0) {
return self::setErrorInfo('会员免费,该专题您不需要支付!');
}
$res = SpecialBuy::PaySpecial($special->id, $uid);
if ($res) return self::setErrorInfo('您已获得专题,无需再次购买!');
break;
case 3:
//参与拼团
if (!$special->is_pink && $special->pink_end_time < date('Y-m-d H:i:s', time())) return self::setErrorInfo('拼团已结束或暂没有开团');
$total_price = $special->pink_money;
$combination_id = $special->id;
$res = SpecialBuy::PaySpecial($special->id, $uid);
if ($res) return self::setErrorInfo('您已获得专题,不能参与拼团!');
$order = self::where(['uid' => $uid, 'cart_id' => $special->id, 'paid' => 1, 'combination_id' => $combination_id, 'pink_id' => $pinkId, 'is_gift' => 0, 'type' => 0, 'status' => 0, 'refund_status' => 0, 'is_del' => 0])->find();
if ($order) return self::setErrorInfo('您已参与拼团,不能参与拼团!');
break;
default:
return self::setErrorInfo('购买方式有误!');
}
if(!$total_price) return self::setErrorInfo('免费专题不需要支付!');
$orderInfo = [
'uid' => $uid,
'mer_id' => $special->mer_id,
'order_id' => self::getNewOrderId(),
'cart_id' => $special->id,
'total_num' => $total_num,
'total_price' => $total_price,
'pay_price' => $total_price,
'pay_type' => $payType,
'combination_id' => $combination_id,
'is_gift' => $pay_type == 1 ? 1 : 0,
'pink_time' => $pay_type == 3 ? $special->pink_time : 0,
'paid' => 0,
'pink_id' => $pinkId,
'unique' => md5(time() . '' . $uid . $special->id),
'cost' => $total_price,
'link_pay_uid' => $userInfo['spread_uid'] ? 0 : $link_pay_uid,
'spread_uid' => $userInfo['spread_uid'] ? $userInfo['spread_uid'] : 0,
'is_del' => 0,
];
$order = self::set($orderInfo);
if (!$order) return self::setErrorInfo('订单生成失败!');
StoreOrderStatus::status($order['id'], 'cache_key_create_order', '订单生成');
return $order;
}
