Authored by xiaowei

优惠码使用

... ... @@ -266,11 +266,12 @@ class CartData
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param string $promotionCode 优惠码
* @param mixed $yohoCoin 使用的YOHO币数量
* @param int $redEnvelopes 红包
* @return array 接口返回的数据
*/
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes)
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode,$promotionCode,$yohoCoin, $redEnvelopes)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.compute';
... ... @@ -280,6 +281,9 @@ class CartData
if (!empty($couponCode)) {
$param['coupon_code'] = $couponCode;
}
if (!empty($promotionCode)) {
$param['promotion_code'] = $promotionCode;
}
if (!empty($yohoCoin)) {
$param['use_yoho_coin'] = $yohoCoin;
}
... ...
... ... @@ -370,16 +370,19 @@ var Order = {
var expressVal = $('.express-list input[name="carriagegroup"]:checked').val();
var biVal = $('#biprice.is-select').val();
var codeVal = $juangroupInput.val();
var promotionVal = $juangroupInput.closest('li').find('#juancode').val();
var cartType = $('.address-manage').attr('cart-type');
var redEnvelopes = $('.use-envelopes input:checked').attr('data-use');
var resultData;
codeVal = !!codeVal ? codeVal : $juangroupInput.closest('li').find('#juancode').val();
codeVal = codeVal ? codeVal : $juangroupInput.closest('li').find('#juancode').val();
resultData = {
cartType: cartType,
deliveryWay: expressVal,
couponCode: codeVal,
promotionCode: promotionVal,
yohoCoin: biVal
//redEnvelopes: e.$useEnvelopesInput.length > 0 ? ~~e.$hasEnvelopes.text().substring(1) : '0'
... ...
... ... @@ -803,11 +803,12 @@ class CartModel
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param string $promotionCode 优惠码
* @param mixed $yohoCoin 使用的YOHO币数量
* @param int $redEnvelopes 红包
* @return array 接口返回的数据
*/
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes)
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode,$promotionCode,$yohoCoin, $redEnvelopes)
{
$result = array('code' => 400, 'message' => self::ERROR_400_MESSAGE, 'data' => array());
... ... @@ -815,7 +816,7 @@ class CartModel
if (!empty($yohoCoin)) {
$yohoCoin = intval($yohoCoin) / 100;
}
$compute = CartData::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes);
$compute = CartData::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode,$promotionCode,$yohoCoin, $redEnvelopes);
if ($compute && isset($compute['code'])) {
/* 商品价格明细 */
if (!empty($compute['data']['promotion_formula_list'])) {
... ...
... ... @@ -388,10 +388,13 @@ class IndexController extends WebAction
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('couponCode', null);
$promotionCode = $this->post('promotionCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$redEnvelopes = $this->post('redEnvelopes', null);
$uid = $this->getUid(false);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes);
//优先取优惠码
$couponCode = $promotionCode ? null : $couponCode;
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $promotionCode, $yohoCoin, $redEnvelopes);
}
$this->echoJson($result);
... ...