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 = $this->full_desc($value['desc']); } $result['full_discount'] = $full_discount; $result['full_desc'] = $full_desc; $result['full_goods'] = $this->full_goods(); //运费 if($this->freight($freight,$offpay_hash,$offpay_hash_batch) == true) { $result['freight'] = $freight; $result['offpay_hash_batch'] = $offpay_hash_batch; $result['offpay_hash'] = $offpay_hash; } else { $result['freight'] = 0; $result['offpay_hash_batch'] = ""; $result['offpay_hash'] = ""; } $result['freight_hash'] = $this->mLogicOut['freight_list']; //红包信息 $result['total_pred'] = doubleval($this->mLogicOut['available_predeposit']); $result['available_pred'] = doubleval($this->available_pred($goods_amount,$full_discount,$result['total_pred'])); $result['usable_pred'] = true; $result['pay_cash_pred'] = $result['goods_amount'] + $result['freight'] - $result['full_discount'] - $result['available_pred']; $result['pay_cash_nopred'] = $result['goods_amount'] + $result['freight'] - $result['full_discount']; //是否可以开增值税发票 $result['vat_deny'] = $this->mLogicOut['vat_deny']; //发票 $result['vat_hash'] = $this->mLogicOut['vat_hash']; return $result; } private function full_desc($desc) { $ret = preg_match('#(.*?).*?#s',$desc,$matches); if($ret != false && count($matches) == 4) { $desc = $matches[1] . $matches[3]; } return $desc; } 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 area_id() { $address_info = $this->mLogicOut['address_info']; if(empty($address_info)) { return false; } else { return intval($address_info['area_id']); } } private function paytype() { return pay_helper::pay_types(); } //运费相关信息 private function freight(&$freight,&$offpay_hash,&$offpay_hash_batch) { $logic_buy = Logic("buy"); $freight_hash = $this->mLogicOut['freight_list']; $city_id = $this->city_id(); $area_id = $this->area_id(); $data = $logic_buy->changeAddr($freight_hash, $city_id, $area_id, $_SESSION['member_id']); if (!empty($data) && $data['state'] == 'success') { $offpay_hash = $data['offpay_hash']; $offpay_hash_batch = $data['offpay_hash_batch']; $freight = 0.00; foreach ($data['content'] as $value) { $freight += $value['value']; } return true; } else { return false; } } 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,$full_discount,$pd_total) { $full = intval($full_discount * 100 + 0.5); $scale = predeposit_helper::scale(); $pred_amound = $this->pred_goods_amount(); if($full > 0) { $pred_amound = intval($pred_amound - ($pred_amound / $goods_amount) * $full_discount); } $pred_cend = intval($pred_amound * $scale * 100 + 0.5); $pd_total = intval($pd_total * 100 + 0.5); return ($pred_cend > $pd_total) ? ($pd_total / 100) : ($pred_cend / 100); } private function pred_goods_amount() { $pred_amount = 0.00; $cart_list = $this->mLogicOut['store_cart_list']; foreach ($cart_list as $store => $cart) { foreach ($cart as $item) { $goods_total = $item['goods_total']; if(intval($item['bl_id']) > 0) { } elseif(!empty($item['groupbuy_info'])) { } elseif(!empty($item['xianshi_info'])) { } else { $pred_amount += $goods_total; } } } Log::record("pred_goods_amount = {$pred_amount}",Log::DEBUG); return $pred_amount; } 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; } }