|
@@ -34,7 +34,8 @@ class member_buyControl extends mbMemberControl
|
|
|
public function calc_cashOp()
|
|
|
{
|
|
|
$cart_ids = explode(',', urldecode($_POST['cart_id']));
|
|
|
- if (empty($cart_ids)) {
|
|
|
+ if (empty($cart_ids))
|
|
|
+ {
|
|
|
return self::outerr(errcode::ErrParamter);
|
|
|
}
|
|
|
|
|
@@ -42,16 +43,22 @@ class member_buyControl extends mbMemberControl
|
|
|
$id_num = $this->pay_goods($cart_ids);
|
|
|
//得到购买数据
|
|
|
$result = $logic_buy->buyStep1($id_num, $_POST['ifcart'], $_SESSION['member_id'], $_SESSION['store_id']);
|
|
|
- if (!$result['state']) {
|
|
|
+ if (!$result['state'])
|
|
|
+ {
|
|
|
return self::outerr(errcode::ErrOrder, $result['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$result = $result['data'];
|
|
|
}
|
|
|
|
|
|
$buy_helper = new buy_first($result, $this->price_calcer());
|
|
|
- if ($buy_helper->check_fcode($error) == false) {
|
|
|
+ if ($buy_helper->check_fcode($error) == false)
|
|
|
+ {
|
|
|
return self::outerr(errcode::ErrPayment, $error);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$result = $buy_helper->format();
|
|
|
$cash_amount = $result['payinfo']['pay_car_pred'];
|
|
|
$total_amonut = $result['payinfo']['pay_car_nopred'];
|
|
@@ -63,7 +70,8 @@ class member_buyControl extends mbMemberControl
|
|
|
public function step_firstOp()
|
|
|
{
|
|
|
$cart_ids = explode(',', urldecode($_POST['cart_id']));
|
|
|
- if (empty($cart_ids)) {
|
|
|
+ if (empty($cart_ids))
|
|
|
+ {
|
|
|
return self::outerr(errcode::ErrParamter);
|
|
|
}
|
|
|
|
|
@@ -73,7 +81,8 @@ class member_buyControl extends mbMemberControl
|
|
|
$id_num = $this->pay_goods($cart_ids);
|
|
|
$result = $logic_buy->buyStep1($id_num, $_POST['ifcart'], session_helper::memberid(), $_SESSION['store_id']);
|
|
|
$fVirual = false;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
#虚拟商品
|
|
|
$logic_buy = Logic('buy_virtual');
|
|
|
$result = $logic_buy->getBuyStep2Data($virtual_goods['goods_id'], $virtual_goods['num'], session_helper::memberid());
|
|
@@ -82,19 +91,22 @@ class member_buyControl extends mbMemberControl
|
|
|
|
|
|
if (!$result['state']) {
|
|
|
return self::outerr(errcode::ErrOrder, $result['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$result = $result['data'];
|
|
|
}
|
|
|
|
|
|
if ($fVirual) {
|
|
|
$buy_helper = new buyv_first($result, $this->price_calcer());
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$buy_helper = new buy_first($result, $this->price_calcer());
|
|
|
}
|
|
|
|
|
|
if ($buy_helper->check_fcode($error) == false) {
|
|
|
return self::outerr(errcode::ErrPayment, $error);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$result = $buy_helper->format();
|
|
|
return self::outsuccess($result);
|
|
|
}
|
|
@@ -106,9 +118,12 @@ class member_buyControl extends mbMemberControl
|
|
|
|
|
|
//存放所购商品ID和数量组成的键值对
|
|
|
$buy_items = [];
|
|
|
- if (is_array($cart_id)) {
|
|
|
- foreach ($cart_id as $value) {
|
|
|
- if (preg_match_all('/^(\d{1,10})\|(\d{1,6})$/', $value, $match)) {
|
|
|
+ if (is_array($cart_id))
|
|
|
+ {
|
|
|
+ foreach ($cart_id as $value)
|
|
|
+ {
|
|
|
+ if (preg_match_all('/^(\d{1,10})\|(\d{1,6})$/', $value, $match))
|
|
|
+ {
|
|
|
if (intval($match[2][0]) > 0) {
|
|
|
$buy_items[$match[1][0]] = $match[2][0];
|
|
|
}
|
|
@@ -160,16 +175,19 @@ class member_buyControl extends mbMemberControl
|
|
|
$result = $logic_buy->buyStep2($param, $_SESSION['member_id'], $_SESSION['member_name'], $_SESSION['member_email']);
|
|
|
if (!$result['state']) {
|
|
|
return self::outerr(errcode::ErrOrder, $result['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$pay_sn = $result['data']['pay_sn'];
|
|
|
$payment = $_POST['payment'];
|
|
|
|
|
|
$payer = new pay_helper($pay_sn);
|
|
|
$out_put = $payer->pay($payment, $err);
|
|
|
|
|
|
- if ($out_put == false) {
|
|
|
+ if ($out_put == false) {
|
|
|
return self::outerr($err['code'], $err['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$out_put['payment'] = $payment;
|
|
|
$out_put['pay_sn'] = $pay_sn;
|
|
|
|
|
@@ -178,13 +196,6 @@ class member_buyControl extends mbMemberControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function check_extra($input, $order_info)
|
|
|
- {
|
|
|
- global $config;
|
|
|
- $order_type = $input[''];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public function step_vsecondOp()
|
|
|
{
|
|
|
$cart_ids = explode(',', urldecode($_POST['cart_id']));
|
|
@@ -200,13 +211,19 @@ class member_buyControl extends mbMemberControl
|
|
|
$input['buyer_msg'] = $_POST['buyer_msg'] ?? '';
|
|
|
$city_id = intval($_POST['city_id']);
|
|
|
|
|
|
- [$fExtra, $extra_info,$order_method] = $this->check_extra($input['goods_id'], $_POST);
|
|
|
+ [$fExtra, $extra_info, $order_method] = $this->extra_info($input['goods_id'], $_POST);
|
|
|
+ if (!$fExtra) {
|
|
|
+ Log::record("step_vsecond error", Log::ERR);
|
|
|
+ return self::outerr(errcode::ErrInputParam, '缺少虚拟商品,额外指定参数.');
|
|
|
+ }
|
|
|
|
|
|
$input['order_from'] = 2;
|
|
|
$result = $logic_buy_virtual->buyStep3($input, session_helper::memberid());
|
|
|
if (!$result['state']) {
|
|
|
return self::outerr(errcode::ErrOrder, $result['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$payment = $_POST['payment'];
|
|
|
$order_sn = $result['data']['order_sn'];
|
|
|
|
|
@@ -215,19 +232,17 @@ class member_buyControl extends mbMemberControl
|
|
|
|
|
|
if ($out_put == false) {
|
|
|
return self::outerr($err['code'], $err['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$out_put['payment'] = $payment;
|
|
|
$out_put['pay_sn'] = $order_sn;
|
|
|
|
|
|
- if($fExtra)
|
|
|
- {
|
|
|
- if(!empty($extra_info)) {
|
|
|
- Model('vr_order')->editOrder(['extra_info' => json_encode($extra_info,JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)],
|
|
|
- ['order_sn' => $order_sn]);
|
|
|
- }
|
|
|
- if(!empty($order_method)) {
|
|
|
- QueueClient::push($order_method,['order_sn' => $order_sn]);
|
|
|
- }
|
|
|
+ if (!empty($extra_info)) {
|
|
|
+ Model('vr_order')->editOrder(['extra_info' => json_encode($extra_info, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)], ['order_sn' => $order_sn]);
|
|
|
+ }
|
|
|
+ if (!empty($order_method)) {
|
|
|
+ QueueClient::push($order_method, ['order_sn' => $order_sn]);
|
|
|
}
|
|
|
|
|
|
return self::outsuccess($out_put);
|
|
@@ -239,19 +254,30 @@ class member_buyControl extends mbMemberControl
|
|
|
{
|
|
|
global $config;
|
|
|
$handlers = $config['vgoods_handlers'];
|
|
|
- if (array_key_exists($goods_id, $handlers)) {
|
|
|
+ if (array_key_exists($goods_id, $handlers))
|
|
|
+ {
|
|
|
$handler = $handlers[$goods_id];
|
|
|
|
|
|
- $extra_params = [];
|
|
|
+ $extra = [];
|
|
|
$types = $handler['input_params'];
|
|
|
- foreach ($types as $item) {
|
|
|
+ foreach ($types as $item)
|
|
|
+ {
|
|
|
if (isset($input[$item])) {
|
|
|
- $extra_params[$item] = $input[$item];
|
|
|
+ $extra['input'][$item] = $input[$item];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log::record("{$goods_id}号商品,在提交订单中,缺少{$item}字段.", Log::ERR);
|
|
|
+ return [false, [], ''];
|
|
|
}
|
|
|
}
|
|
|
- return [true, $extra_params, $handler['order_method']];
|
|
|
+
|
|
|
+ if (!empty($handler['additional'])) {
|
|
|
+ $extra['additional'] = $handler['additional'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, $extra, $handler['order_method']];
|
|
|
}
|
|
|
- return [false, [], ''];
|
|
|
+ return [true, [], ''];
|
|
|
}
|
|
|
|
|
|
public function pay_confirmOp()
|
|
@@ -265,18 +291,18 @@ class member_buyControl extends mbMemberControl
|
|
|
|
|
|
if ($paied == false) {
|
|
|
return self::outerr($err['code'], $err['msg']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
session_helper::add_order();
|
|
|
if ($fcode_state == 1) {
|
|
|
- return self::outsuccess(['special_list' => null,
|
|
|
- 'summary' => null,
|
|
|
- 'groupbuy' => null,
|
|
|
- 'limitime' => null,
|
|
|
- 'bundling' => null,
|
|
|
- 'mobile_page' => mobile_page(1)]);
|
|
|
- } else {
|
|
|
+ return self::outsuccess(['special_list' => null, 'summary' => null, 'groupbuy' => null, 'limitime' => null, 'bundling' => null, 'mobile_page' => mobile_page(1)]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
$result = fcode\send_manager::instance()->fetch($amount, $pay_sn, session_helper::mobile(), session_helper::session_id());
|
|
|
- if ($result != false) {
|
|
|
+ if ($result != false)
|
|
|
+ {
|
|
|
$order_pay = Model('order_pay');
|
|
|
$order_pay->where(['pay_sn' => $pay_sn])->update(['fcode_state' => 1]);
|
|
|
|
|
@@ -285,7 +311,8 @@ class member_buyControl extends mbMemberControl
|
|
|
|
|
|
if ($this->mFcodeBannerID > 0) {
|
|
|
$blocks = special_manager::instance()->special($this->mFcodeBannerID, $unused_gids);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$blocks = [];
|
|
|
}
|
|
|
|
|
@@ -295,7 +322,8 @@ class member_buyControl extends mbMemberControl
|
|
|
|
|
|
$fcodes = [];
|
|
|
$gids = [];
|
|
|
- foreach ($result['fcode'] as $item) {
|
|
|
+ foreach ($result['fcode'] as $item)
|
|
|
+ {
|
|
|
$fcoder = new fcode\mfcode($item);
|
|
|
$fcode = $fcoder->format();
|
|
|
if ($fcode != false) {
|
|
@@ -312,20 +340,11 @@ class member_buyControl extends mbMemberControl
|
|
|
$helper = new goods_helper($this->price_calcer(), false);
|
|
|
$ret = $helper->cart_summary($gids, $related_goods);
|
|
|
|
|
|
- return self::outsuccess(['special_list' => $blocks,
|
|
|
- 'fcodes' => $fcodes,
|
|
|
- 'summary' => $ret['summary'],
|
|
|
- 'groupbuy' => $ret['groupbuy'],
|
|
|
- 'limitime' => $ret['limitime'],
|
|
|
- 'bundling' => $ret['bundling'],
|
|
|
- 'mobile_page' => mobile_page(1)]);
|
|
|
- } else {
|
|
|
- return self::outsuccess(['special_list' => null,
|
|
|
- 'summary' => null,
|
|
|
- 'groupbuy' => null,
|
|
|
- 'limitime' => null,
|
|
|
- 'bundling' => null,
|
|
|
- 'mobile_page' => mobile_page(1)]);
|
|
|
+ return self::outsuccess(['special_list' => $blocks, 'fcodes' => $fcodes, 'summary' => $ret['summary'], 'groupbuy' => $ret['groupbuy'], 'limitime' => $ret['limitime'], 'bundling' => $ret['bundling'], 'mobile_page' => mobile_page(1)]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return self::outsuccess(['special_list' => null, 'summary' => null, 'groupbuy' => null, 'limitime' => null, 'bundling' => null, 'mobile_page' => mobile_page(1)]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -334,7 +353,8 @@ class member_buyControl extends mbMemberControl
|
|
|
private function fcode_blocks($fcodes)
|
|
|
{
|
|
|
$blocks = [];
|
|
|
- foreach ($fcodes as $fcode) {
|
|
|
+ foreach ($fcodes as $fcode)
|
|
|
+ {
|
|
|
$block = [];
|
|
|
$block['item_title'] = '';
|
|
|
$block['item_type'] = 'home1';
|
|
@@ -358,7 +378,8 @@ class member_buyControl extends mbMemberControl
|
|
|
{
|
|
|
$logic_buy = Logic('buy');
|
|
|
$data = $logic_buy->changeAddr($_POST['freight_hash'], $_POST['city_id'], $_POST['area_id'], $_SESSION['member_id']);
|
|
|
- if (!empty($data) && $data['state'] == 'success') {
|
|
|
+ if (!empty($data) && $data['state'] == 'success')
|
|
|
+ {
|
|
|
$result['offpay_hash'] = $data['offpay_hash'];
|
|
|
$result['offpay_hash_batch'] = $data['offpay_hash_batch'];
|
|
|
|
|
@@ -369,14 +390,17 @@ class member_buyControl extends mbMemberControl
|
|
|
$result['freight'] = $freight;
|
|
|
|
|
|
return self::outsuccess($result);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
return self::outerr(errcode::ErrOrder, '地址修改失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private function pay_goods($cart_ids)
|
|
|
{
|
|
|
- if (boolval($_POST['ifcart']) == true) {
|
|
|
+ if (boolval($_POST['ifcart']) == true)
|
|
|
+ {
|
|
|
$mod_cart = Model('cart');
|
|
|
$items = $mod_cart->listCart('db', ['cart_id' => ['in', $cart_ids]], false);
|
|
|
$id_num = [];
|
|
@@ -386,7 +410,8 @@ class member_buyControl extends mbMemberControl
|
|
|
$id_num[] = "{$cart_id}|{$goods_num}";
|
|
|
}
|
|
|
return $id_num;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$id_num = $cart_ids;
|
|
|
return $id_num;
|
|
|
}
|
|
@@ -403,7 +428,8 @@ class member_buyControl extends mbMemberControl
|
|
|
$member_info = $model_member->getMemberInfoByID($_SESSION['member_id']);
|
|
|
if ($member_info['member_paypwd'] == md5($_POST['password'])) {
|
|
|
return self::outsuccess(['result' => '1']);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
return self::outerr(errcode::ErrOrder, '密码错误');
|
|
|
}
|
|
|
}
|