|
@@ -0,0 +1,203 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * Created by PhpStorm.
|
|
|
+ * User: stanley-king
|
|
|
+ * Date: 16/9/19
|
|
|
+ * Time: 下午6:48
|
|
|
+ */
|
|
|
+
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/activity_helper.php');
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/goods_helper.php');
|
|
|
+
|
|
|
+class buy_first
|
|
|
+{
|
|
|
+ private $mLogicOut;
|
|
|
+ public function __construct($logic_out)
|
|
|
+ {
|
|
|
+ $this->mLogicOut = $logic_out;
|
|
|
+ }
|
|
|
+ //商品金额相关信息
|
|
|
+ private function payinfo()
|
|
|
+ {
|
|
|
+ $result = [];
|
|
|
+
|
|
|
+ //商品总价,红包可抵扣,满减金额
|
|
|
+ $goods_amount = 0.00;
|
|
|
+ $store_goods_total = $this->mLogicOut['store_goods_total'];
|
|
|
+ foreach ($store_goods_total as $store_id => $value) {
|
|
|
+ $goods_amount += doubleval($value);
|
|
|
+ }
|
|
|
+
|
|
|
+ $result['goods_amount'] = $goods_amount;
|
|
|
+
|
|
|
+ //满送
|
|
|
+ $full_discount = 0.00;
|
|
|
+ $full_desc = '';
|
|
|
+ $store_mansong_rule_list = $this->mLogicOut['store_mansong_rule_list'];
|
|
|
+ foreach ($store_mansong_rule_list as $store_id => $value) {
|
|
|
+ $full_discount += doubleval($value['discount']);
|
|
|
+ $full_desc = $value['mansong_name'];
|
|
|
+ }
|
|
|
+ $result['full_discount'] = $full_discount;
|
|
|
+ $result['full_desc'] = $full_desc;
|
|
|
+ $result['full_goods'] = $this->full_goods();
|
|
|
+
|
|
|
+ //运费
|
|
|
+ $result['freight'] = $this->freight();
|
|
|
+ $result['freight_hash'] = $this->mLogicOut['freight_list'];
|
|
|
+
|
|
|
+ //红包信息
|
|
|
+ $result['total_pred'] = doubleval($this->mLogicOut['available_predeposit']);
|
|
|
+ $result['available_pred'] = $this->available_pred($goods_amount);
|
|
|
+ $result['usable_pred'] = true;
|
|
|
+
|
|
|
+ $result['vat_deny'] = $this->mLogicOut['vat_deny'];
|
|
|
+ $result['vat_hash'] = $this->mLogicOut['vat_hash'];
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function full_goods()
|
|
|
+ {
|
|
|
+ $store_mansong_rule_list = $this->mLogicOut['store_mansong_rule_list'];
|
|
|
+ foreach ($store_mansong_rule_list as $store_id => $value) {
|
|
|
+ return intval($value['goods_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function city_id()
|
|
|
+ {
|
|
|
+ $address_info = $this->mLogicOut['address_info'];
|
|
|
+ if(empty($address_info)) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return intval($address_info['city_id']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private function paytype()
|
|
|
+ {
|
|
|
+ //支付宝,微信,招商银行,各自的描述语
|
|
|
+ $types = [];
|
|
|
+ $types[] = array("payment" => "wxpay","desc" => "");
|
|
|
+ $types[] = array("payment" => "alipay","desc" => "");
|
|
|
+ $types[] = array("payment" => "cmbchina","desc" => "");
|
|
|
+ return $types;
|
|
|
+ }
|
|
|
+ //运费相关信息
|
|
|
+ private function freight()
|
|
|
+ {
|
|
|
+ $logic_buy_1 = Logic('buy_1');
|
|
|
+ $logic_buy = Logic("buy");
|
|
|
+ $freight_hash = $this->mLogicOut['freight_list'];
|
|
|
+ $freight_list = $logic_buy->buyDecrypt($freight_hash, $_SESSION['member_id']);
|
|
|
+ $city_id = $this->city_id();
|
|
|
+ $store_freight_total = $logic_buy_1->calcStoreFreight($freight_list,$city_id);
|
|
|
+
|
|
|
+ $freight = 0.00;
|
|
|
+ foreach ($store_freight_total as $key => $value) {
|
|
|
+ $freight += doubleval($value);
|
|
|
+ }
|
|
|
+ return $freight;
|
|
|
+ }
|
|
|
+ private function goods_ids()
|
|
|
+ {
|
|
|
+ $ids = [];
|
|
|
+ $sent_id = $this->full_goods();
|
|
|
+ if($sent_id > 0) {
|
|
|
+ $ids[] = $sent_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ $carts = $this->goods_list();
|
|
|
+ foreach ($carts as $item)
|
|
|
+ {
|
|
|
+ if($item['bl_id'] > 0)
|
|
|
+ {
|
|
|
+ $bl_goods = activity_helper::bundling_goods($item['bl_id']);
|
|
|
+ if($bl_goods != false) {
|
|
|
+ foreach ($bl_goods as $gid) {
|
|
|
+ $ids[] = $gid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $ids[] = $item['goods_id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $ids;
|
|
|
+ }
|
|
|
+ private function summary()
|
|
|
+ {
|
|
|
+ $goods_ids = $this->goods_ids();
|
|
|
+
|
|
|
+ $helper = new goods_helper();
|
|
|
+ $summaries = $helper->get_summary($goods_ids,$related_goods);
|
|
|
+ $summary_list = $summaries['summary'];
|
|
|
+ if(!empty($related_goods)) {
|
|
|
+ $related_summary = $helper->cart_summary($related_goods,$x);
|
|
|
+ $summary_list = array_merge($summary_list,$related_summary['summary']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $ret['summary'] = $summary_list;
|
|
|
+ $ret['groupbuy'] = $summaries['groupbuy'];
|
|
|
+ $ret['limitime'] = $summaries['limitime'];
|
|
|
+ $ret['bundling'] = $summaries['bundling'];
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function address()
|
|
|
+ {
|
|
|
+ return $this->mLogicOut['address_info'];
|
|
|
+ }
|
|
|
+
|
|
|
+ private function goods_list()
|
|
|
+ {
|
|
|
+ //购物车中商品列表
|
|
|
+ $goods_list = [];
|
|
|
+ $store_cart_list = $this->mLogicOut['store_cart_list'];
|
|
|
+ foreach ($store_cart_list as $store_id => $carts)
|
|
|
+ {
|
|
|
+ foreach ($carts as $value) {
|
|
|
+ $item['goods_id'] = intval($value['goods_id']);
|
|
|
+ $item['goods_num'] = intval($value['goods_num']);
|
|
|
+ $item['bl_id'] = intval($value['bl_id']);
|
|
|
+
|
|
|
+ $goods_list[] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $goods_list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function invoice()
|
|
|
+ {
|
|
|
+ //发票信息
|
|
|
+ return $this->mLogicOut['inv_info'];;
|
|
|
+ }
|
|
|
+ private function available_pred($goods_amount)
|
|
|
+ {
|
|
|
+ return intval($goods_amount * 0.3 * 100 + 0.5) / 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function format()
|
|
|
+ {
|
|
|
+ $result = [];
|
|
|
+ $result['payinfo'] = $this->payinfo();
|
|
|
+ $result['paytype'] = $this->paytype();
|
|
|
+ $result['address'] = $this->address();
|
|
|
+ $result['invoice'] = $this->invoice();
|
|
|
+ $result['goods_list'] = $this->goods_list();
|
|
|
+
|
|
|
+ $summary = $this->summary();
|
|
|
+ $result['summary'] = $summary['summary'];
|
|
|
+ $result['groupbuy'] = $summary['groupbuy'];
|
|
|
+ $result['limitime'] = $summary['limitime'];
|
|
|
+ $result['bundling'] = $summary['bundling'];
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+}
|