Files
addons
app_download_files
extend
hyhproject
admin
app
common
home
home2
mobile2
common
conf
controller
Alipays.php
Areas.php
Base.php
Brands.php
Carts.php
Cashconfigs.php
Cashdraws.php
Demo.php
Error.php
Favorites.php
Goods.php
Goodsappraises.php
Goodscats.php
Goodsconsult.php
Index.php
Invoices.php
Juhui.php
Logmoneys.php
Messages.php
News.php
Ordercomplains.php
Orderrefunds.php
Orders.php
Promotion.php
Shops.php
Switchs.php
Unionpays.php
Useraddress.php
Users.php
Userscores.php
Wallets.php
Weixinpays.php
model
validate
view
wechat2
.htaccess
command.php
mobile
oss
static
thinkphp
upload
vendor
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5B854518.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
index.html
index.php
reg.lock
robots.txt
qlg.tsgz.moe/hyhproject/mobile2/controller/Carts.php
2019-09-06 23:53:10 +08:00

153 lines
4.3 KiB
PHP
Executable File

<?php
namespace wstmart\mobile\controller;
use wstmart\common\model\Carts as M;
use wstmart\common\model\UserAddress;
use wstmart\common\model\Payments;
/**
* ============================================================================
* 购物车控制器
*/
class Carts extends Base{
// 前置方法执行列表
protected $beforeActionList = [
'checkAuth'
];
/**
* 批量修改购物车状态
*/
public function batchChangeCartGoods(){
$m = new M();
return $m->batchChangeCartGoods();
}
/**
* 查看购物车列表
*/
public function index(){
$m = new M();
$carts = $m->getCarts(false);
$this->assign('carts',$carts);
return $this->fetch('carts');
}
/**
* 加入购物车
*/
public function addCart(){
$m = new M();
$rs = $m->addCart();
$rs['cartNum'] = WSTCartNum();
return $rs;
}
/**
* 修改购物车商品状态
*/
public function changeCartGoods(){
$m = new M();
$rs = $m->changeCartGoods();
return $rs;
}
/**
* 删除购物车里的商品
*/
public function delCart(){
$m = new M();
$rs= $m->delCart();
return $rs;
}
/**
* 计算运费、惠宝和总商品价格
*/
public function getCartMoney(){
$m = new M();
$data = $m->getCartMoney();
return $data;
}
/**
* 计算运费、惠宝和总商品价格/虚拟商品
*/
public function getQuickCartMoney(){
$m = new M();
$data = $m->getQuickCartMoney();
return $data;
}
/**
* 跳去购物车结算页面
*/
public function settlement(){
$m = new M();
//获取一个用户地址
$addressId = (int)input('addressId');
$ua = new UserAddress();
if($addressId>0){
$userAddress = $ua->getById($addressId);
}else{
$userAddress = $ua->getDefaultAddress();
}
$this->assign('userAddress',$userAddress);
//获取支付方式
$pa = new Payments();
$payments = $pa->getByGroup('2');
$areaId2 = isset($userAddress['areaId2']) ? $userAddress['areaId2'] : 0;
//dump($payments);
//获取已选的购物车商品
$carts = $m->getCarts(true, 0, $areaId2);
//hook("mobileControllerCartsSettlement",["carts"=>$carts,"payments"=>&$payments]);
//ect整合相关优惠还有判断不能和在线支付商品一块
// hook("ectIntegration",["carts"=>&$carts,'isSettlement'=>false,'uId'=>(int)session('WST_USER.userId')]);
$this->assign('payments',$payments);
//获取用户惠宝
$user = model('users')->getFieldsById((int)session('WST_USER.userId'),'userScore');
//计算可用惠宝和金额
$goodsTotalMoney = (int)(($carts['goodsTotalMoney'] - $carts['promotionMoney'] - $carts['allShippingMoney']) * HuiScale());//$carts['goodsTotalMoney']; 惠宝最多可抵用20% mark 20170907
$goodsTotalScore = WSTScoreToMoney($goodsTotalMoney,true);
$useOrderScore =0;
$useOrderMoney = 0;
if($user['userScore']>$goodsTotalScore){
$useOrderScore = $goodsTotalScore;
$useOrderMoney = $goodsTotalMoney;
}else{
$useOrderScore = $user['userScore'];
$useOrderMoney = WSTScoreToMoney($useOrderScore);
}
$this->assign('userOrderScore',$useOrderScore);
$this->assign('userOrderMoney',$useOrderMoney);
$this->assign('carts',$carts);
return $this->fetch('settlement');
}
/**
* 跳去虚拟商品购物车结算页面
*/
public function quickSettlement(){
$m = new M();
//获取支付方式
$pa = new Payments();
$payments = $pa->getByGroup('2');
$this->assign('payments',$payments);
//获取用户惠宝
$user = model('users')->getFieldsById((int)session('WST_USER.userId'),'userScore');
//获取已选的购物车商品
$carts = $m->getQuickCarts();
//计算可用惠宝和金额
$goodsTotalMoney = (int)($carts['goodsTotalMoney'] * HuiScale());//$carts['goodsTotalMoney']; 惠宝最多可抵用20% mark 20170907
$goodsTotalScore = WSTScoreToMoney($goodsTotalMoney,true);
$useOrderScore =0;
$useOrderMoney = 0;
if($user['userScore']>$goodsTotalScore){
$useOrderScore = $goodsTotalScore;
$useOrderMoney = $goodsTotalMoney;
}else{
$useOrderScore = $user['userScore'];
$useOrderMoney = WSTScoreToMoney($useOrderScore);
}
$this->assign('userOrderScore',$useOrderScore);
$this->assign('userOrderMoney',$useOrderMoney);
$this->assign('carts',$carts);
return $this->fetch('settlement_quick');
}
}