Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

View File

@ -0,0 +1,16 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Ads as M;
/**
* ============================================================================
* 广告控制器
*/
class Ads extends Base{
/**
* 记录点击次数
*/
public function recordClick(){
$m = new M();
return $m->recordClick();
}
}

View File

@ -0,0 +1,283 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Payments as M;
use wstmart\common\model\Orders as OM;
use wstmart\common\model\LogMoneys as LM;
use wstmart\common\model\ChargeItems as CM;
/**
* ============================================================================
* 阿里支付控制器
*/
class Alipays extends Base{
/**
* 初始化
*/
private $aliPayConfig;
public function _initialize() {
$this->aliPayConfig = array();
$m = new M();
$this->aliPayConfig = $m->getPayment("alipays");
}
/**
* 生成支付代码
*/
function getAlipaysUrl(){
$payObj = input("payObj/s");
$m = new OM();
$obj = array();
$data = array();
$orderAmount = 0;
$out_trade_no = "";
$extra_common_param = "";
$subject = "";
$body = "";
if($payObj=="recharge"){//充值
$itmeId = (int)input("itmeId/d");
$orderAmount = 0;
if($itmeId>0){
$cm = new CM();
$item = $cm->getItemMoney($itmeId);
$orderAmount = isSet($item["chargeMoney"])?$item["chargeMoney"]:0;
}else{
$orderAmount = (int)input("needPay/d");
}
$shopId = (int)session('WST_USER.shopId');
$targetType = ($shopId>0)?1:0;
$targetId = (int)session('WST_USER.userId');
if($targetType==1){//商家
$targetId = $shopId;
}
$data["status"] = $orderAmount>0?1:-1;
$out_trade_no = WSTOrderNo();
$extra_common_param = $payObj."@".$targetId."@".$targetType."@".$itmeId;
$subject = '钱包充值 ¥'.$orderAmount.'元';
$body = '钱包充值';
}else{
$obj["orderNo"] = input("orderNo/s");
$obj["isBatch"] = (int)input("isBatch/d");
$data = $m->checkOrderPay($obj);
if($data["status"]==1){
$userId = (int)session('WST_USER.userId');
$obj["userId"] = $userId;
$order = $m->getPayOrders($obj);
$orderAmount = $order["needPay"];
$payRand = $order["payRand"];
$out_trade_no = $obj["orderNo"]."a".$payRand;
$extra_common_param = $payObj."@".$userId."@".$obj["isBatch"];
$subject = '支付购买商品费用'.$orderAmount.'元';
$body = '支付订单费用';
}
}
if($data["status"]==1){
$return_url = url("home/alipays/response","",true,true);
$notify_url = url("home/alipays/aliNotify","",true,true);
$parameter = array(
'extra_common_param'=> $extra_common_param,
'service' => 'create_direct_pay_by_user',
'partner' => $this->aliPayConfig['parterID'],
'_input_charset' => "utf-8",
'notify_url' => $notify_url,
'return_url' => $return_url,
/* 业务参数 */
'subject' => $subject,
'body' => $body,
'out_trade_no' => $out_trade_no,
'total_fee' => $orderAmount,
'quantity' => 1,
'payment_type' => 1,
/* 物流参数 */
'logistics_type' => 'EXPRESS',
'logistics_fee' => 0,
'logistics_payment' => 'BUYER_PAY_AFTER_RECEIVE',
/* 买卖双方信息 */
'seller_email' => $this->aliPayConfig['payAccount']
);
ksort($parameter);
reset($parameter);
$param = '';
$sign = '';
foreach ($parameter AS $key => $val){
$param .= "$key=" .urlencode($val). "&";
$sign .= "$key=$val&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1). $this->aliPayConfig['parterKey'];
$url = 'https://mapi.alipay.com/gateway.do?'.$param. '&sign='.md5($sign).'&sign_type=MD5';
$data["url"] = $url;
}
return $data;
}
/**
* 支付结果同步回调
*/
function response(){
$m = new OM();
$request = $_GET;
unset($request['_URL_']);
$payRes = self::notify($request);
if($payRes['status']){
$extras = explode("@",$_GET['extra_common_param']);
if($extras[0]=="recharge"){//充值
if($extras[2]==1){
$this->redirect(url("home/logmoneys/shopmoneys"));
}else{
$this->redirect(url("home/logmoneys/usermoneys"));
}
}else{
$this->redirect(url("home/alipays/paysuccess"));
}
}else{
$this->error('支付失败');
}
}
/**
* 支付结果异步回调
*/
function aliNotify(){
$m = new OM();
$request = $_POST;
$payRes = self::notify($request);
if($payRes['status']){
$extras = explode("@",$_POST['extra_common_param']);
$rs = array();
if($extras[0]=="recharge"){//充值
$targetId = (int)$extras [1];
$targetType = (int)$extras [2];
$itemId = (int)$extras [3];
$obj = array ();
$obj["trade_no"] = $_POST['trade_no'];
$obj["out_trade_no"] = $_POST["out_trade_no"];;
$obj["targetId"] = $targetId;
$obj["targetType"] = $targetType;
$obj["itemId"] = $itemId;
$obj["total_fee"] = $_POST['total_fee'];
$obj["payFrom"] = 'alipays';
// 支付成功业务逻辑
$m = new LM();
$rs = $m->complateRecharge ( $obj );
}else{
//商户订单号
$obj = array();
$tradeNo = explode("a",$_POST['out_trade_no']);
$obj["trade_no"] = $_POST['trade_no'];
$obj["out_trade_no"] = $tradeNo[0];
$obj["total_fee"] = $_POST['total_fee'];
$obj["userId"] = $extras[1];
$obj["isBatch"] = $extras[2];
$obj["payFrom"] = 'alipays';
//支付成功业务逻辑
$rs = $m->complatePay($obj);
}
if($rs["status"]==1){
echo 'success';
}else{
echo 'fail';
}
}else{
echo 'fail';
}
}
/**
* 支付回调接口
*/
function notify($request){
$returnRes = array('info'=>'','status'=>false);
$request = $this->argSort($request);
// 检查数字签名是否正确
$isSign = $this->getSignVeryfy($request);
if (!$isSign){//签名验证失败
$returnRes['info'] = '签名验证失败';
return $returnRes;
}
if ($request['trade_status'] == 'TRADE_SUCCESS' || $request['trade_status'] == 'TRADE_FINISHED'){
$returnRes['status'] = true;
}
return $returnRes;
}
/**
* 获取返回时的签名验证结果
*/
function getSignVeryfy($para_temp) {
$parterKey = $this->aliPayConfig["parterKey"];
//除去待签名参数数组中的空值和签名参数
$para_filter = $this->paraFilter($para_temp);
//对待签名参数数组排序
$para_sort = $this->argSort($para_filter);
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
$prestr = $this->createLinkstring($para_sort);
$isSgin = false;
$isSgin = $this->md5Verify($prestr, $para_temp['sign'], $parterKey);
return $isSgin;
}
/**
* 验证签名
*/
function md5Verify($prestr, $sign, $key) {
$prestr = $prestr . $key;
$mysgin = md5($prestr);
if($mysgin == $sign) {
return true;
}else {
return false;
}
}
/**
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
*/
function createLinkstring($para) {
$arg = "";
while (list ($key, $val) = each ($para)) {
$arg.=$key."=".$val."&";
}
//去掉最后一个&字符
$arg = substr($arg,0,count($arg)-2);
//如果存在转义字符,那么去掉转义
if(get_magic_quotes_gpc()){$arg = stripslashes($arg);}
return $arg;
}
/**
* 除去数组中的空值和签名参数
*/
function paraFilter($para) {
$para_filter = array();
while (list ($key, $val) = each ($para)) {
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}
/**
* 对数组排序
*/
function argSort($para) {
ksort($para);
reset($para);
return $para;
}
/**
* 检查支付结果
*/
public function paySuccess() {
return $this->fetch('order_pay_step3');
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Areas as M;
/**
* ============================================================================
* 地区控制器
*/
class Areas extends Base{
/**
* 获取地区信息
*/
public function listQuery(){
$m = new M();
$rs = $m->listQuery();
return WSTReturn('', 1,$rs);
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 基础控制器
*/
use think\Controller;
class Base extends Controller {
protected $is_icp = 1;
public function __construct(){
parent::__construct();
$this->assign("v",WSTConf('CONF.wstVersion')."_".WSTConf('CONF.wstPCStyleId'));
hook('homeControllerBase');
if(WSTConf('CONF.seoMallSwitch')==0){
$this->redirect('home/switchs/index');
exit;
}
$this->assign('is_icp',$this->is_icp);
}
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
{
$style = WSTConf('CONF.wsthomeStyle')?WSTConf('CONF.wsthomeStyle'):'default';
$replace['__STYLE__'] = str_replace('/index.php','',\think\Request::instance()->root()).'/hyhproject/home/view/'.WSTConf('CONF.wsthomeStyle');
return $this->view->fetch($style."/".$template, $vars, $replace, $config);
}
/**
* 上传图片
*/
public function uploadPic(){
return WSTUploadPic(0);
}
/**
* 编辑器上传文件
*/
public function editorUpload(){
return WSTEditUpload(0);
}
/**
* 获取验证码
*/
public function getVerify(){
WSTVerify();
}
// 登录验证方法--用户
protected function checkAuth(){
$USER = session('WST_USER');
if(empty($USER)){
if(request()->isAjax()){
die('{"status":-999,"msg":"您还未登录"}');
}else{
$this->redirect('home/users/login');
exit;
}
}
}
//登录验证方法--商家
protected function checkShopAuth(){
$USER = session('WST_USER');
if(empty($USER) || $USER['userType']!=1){
if(request()->isAjax()){
die('{"status":-999,"msg":"您还未登录"}');
}else{
$this->redirect('home/shops/login');
exit;
}
}
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Brands as M;
/**
* ============================================================================
* 品牌控制器
*/
class Brands extends Base{
/**
* 品牌街
*/
public function index(){
$m = new M();
$pagesize = 25;
$brandsList = $m->pageQuery($pagesize);
$this->assign('list',$brandsList);
$g = model('goodsCats');
$goodsCats = $g->listQuery(0);
$this->assign('goodscats',$goodsCats);
$selectedId = (int)input("id");
$this->assign('selectedId',$selectedId);
return $this->fetch('brands_list');
}
/**
* 获取品牌列表
*/
public function listQuery(){
$m = new M();
return ['status'=>1,'list'=>$m->listQuery(input('post.catId/d'))];
}
}

View File

@ -0,0 +1,318 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Carts as M;
use wstmart\common\model\Payments as PM;
/**
* ============================================================================
* 购物车控制器
*/
class Carts extends Base{
protected $beforeActionList = ['checkAuth'];
/**
* 加入购物车
*/
public function addCart(){
$m = new M();
$rs = $m->addCart();
return $rs;
}
/**
* 查看购物车列表
*/
public function index(){
$m = new M();
$carts = $m->getCarts(false);
$this->assign('carts',$carts);
return $this->fetch('carts');
}
/**
* 删除购物车里的商品
*/
public function delCart(){
$m = new M();
$rs= $m->delCart();
return $rs;
}
/**
* 虚拟商品下单
*/
public function quickSettlement(){
$m = new M();
//获取支付方式
$pm = new PM();
$payments = $pm->getByGroup('1',1);
$carts = $m->getQuickCarts();
if(empty($carts['carts'])){
$this->assign('message','Sorry~您还未选择商品。。。');
return $this->fetch('error_msg');
}
hook("homeControllerCartsSettlement",["carts"=>$carts,"payments"=>&$payments]);
//获取用户惠宝
$user = model('users')->getFieldsById((int)session('WST_USER.userId'),'userScore');
//计算可用惠宝和金额
$goodsTotalMoney = $carts['goodsTotalMoney']-$carts['promotionMoney'];
$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('payments',$payments);
$this->assign('carts',$carts);
return $this->fetch('settlement_quick');
}
/**
* 跳去购物车结算页面
*/
public function settlement(){
$m = new M();
//获取一个用户地址
$userAddress = model('UserAddress')->getDefaultAddress();
$this->assign('userAddress',$userAddress);
//获取省份
$areas = model('Areas')->listQuery();
$this->assign('areaList',$areas);
//获取支付方式
$pm = new PM();
$payments = $pm->getByGroup('1');
$carts = $m->getCarts(true);
if(empty($carts['carts'])){
$this->assign('message','Sorry~您还未选择商品。。。');
return $this->fetch('error_msg');
}
hook("homeControllerCartsSettlement",["carts"=>$carts,"payments"=>&$payments]);
//获取用户惠宝
$user = model('users')->getFieldsById((int)session('WST_USER.userId'),'userScore');
//计算可用惠宝和金额
$goodsTotalMoney = (($carts['goodsTotalMoney']-$carts['allShippingMoney']-$carts['promotionMoney']) * HuiScale());//$carts['goodsTotalMoney']-$carts['promotionMoney'];//惠宝最多可抵用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);
// dump($carts);die;
$this->assign('payments',$payments);
return $this->fetch('settlement');
}
/**
* 计算运费、惠宝和总商品价格
*/
public function getCartMoney(){
$m = new M();
$data = $m->getCartMoney();
// dump($data);die;
return $data;
}
/**
* 计算运费、惠宝和总商品价格
*/
public function getQuickCartMoney(){
$m = new M();
$data = $m->getQuickCartMoney();
return $data;
}
/**
* 修改购物车商品状态
*/
public function changeCartGoods(){
$m = new M();
$rs = $m->changeCartGoods();
return $rs;
}
/**
* 批量修改购物车商品状态
*/
public function batchChangeCartGoods(){
$m = new M();
$rs = $m->batchChangeCartGoods();
return $rs;
}
/**
* 获取购物车商品
*/
public function getCart(){
$m = new M();
$carts = $m->getCarts(false);
return WSTReturn("", 1,$carts);
}
/**
* 获取购物车信息
*/
public function getCartInfo(){
$m = new M();
$rs = $m->getCartInfo();
return WSTReturn("", 1,$rs);
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\CashConfigs as M;
/**
* ============================================================================
* 提现账号控制器
*/
class Cashconfigs extends Base{
protected $beforeActionList = ['checkAuth'];
/**
* 获取用户数据
*/
public function pageQuery(){
$userId = (int)session('WST_USER.userId');
$data = model('CashConfigs')->pageQuery(0,$userId);
return WSTReturn("", 1,$data);
}
/**
* 跳转新增/编辑页面
*/
public function toEdit(){
$id = (int)input('id');
$object = [];
$m = new M();
if($id>0){
$object = $m->getById($id);
}else{
$object = $m->getEModel('cash_configs');
$object['accAreaIdPath'] = '';
}
$this->assign('object',$object);
$this->assign('areas',model('areas')->listQuery(0));
$this->assign('banks',model('banks')->listQuery(0));
return $this->fetch('users/cashdraws/box_config');
}
/**
* 新增
*/
public function add(){
$m = new M();
return $m->add();
}
/**
* 编辑
*/
public function edit(){
$m = new M();
return $m->edit();
}
/**
* 删除
*/
public function del(){
$m = new M();
return $m->del();
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\CashDraws as M;
use wstmart\common\model\Users as MUsers;
use wstmart\common\model\Shops as MShops;
/**
* ============================================================================
* 提现记录控制器
*/
class Cashdraws extends Base{
protected $beforeActionList = [
'checkAuth'=>['only'=>'index,pagequery,toedit,drawmoney'],
'checkShopAuth'=>['only'=>'shopindex,pagequerybyshop,toeditbyshop,drawmoneybyshop']
];
/**
* 查看用户资金流水
*/
public function index(){
return $this->fetch('users/cashdraws/list');
}
/**
* 获取用户数据
*/
public function pageQuery(){
$userId = (int)session('WST_USER.userId');
$data = model('CashDraws')->pageQuery(0,$userId);
return WSTReturn("", 1,$data);
}
/**
* 跳转提现页面
*/
public function toEdit(){
$userId = (int)session('WST_USER.userId');
$this->assign('accs',model('CashConfigs')->listQuery(0,$userId));
$m = new MUsers();
$user = $m->getFieldsById($userId,["userMoney","rechargeMoney"]);
$this->assign('user',$user);
return $this->fetch('users/cashdraws/box_draw');
}
/**
* 提现
*/
public function drawMoney(){
$m = new M();
return $m->drawMoney();
}
/**
* 查看用户资金流水
*/
public function shopIndex(){
return $this->fetch('shops/cashdraws/list');
}
/**
* 获取用户数据
*/
public function pageQueryByShop(){
$shopId = (int)session('WST_USER.shopId');
$data = model('CashDraws')->pageQuery(1,$shopId);
return WSTReturn("", 1,$data);
}
/**
* 申请提现
*/
public function toEditByShop(){
$this->assign('object',model('shops')->getShopAccount());
$m = new MShops();
$shopId = (int)session('WST_USER.shopId');
$shop = $m->getFieldsById($shopId,["shopMoney","rechargeMoney"]);
$this->assign('shop',$shop);
return $this->fetch('shops/cashdraws/box_draw');
}
/**
* 提现
*/
public function drawMoneyByShop(){
$m = new M();
return $m->drawMoneyByShop();
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 错误处理控制器
*/
class Error extends Base{
public function index(){
header("HTTP/1.0 404 Not Found");
return $this->fetch('error_sys');
}
public function goods(){
$this->assign('message','很抱歉,您要找的商品已经找不到了~');
return $this->fetch('error_msg');
}
public function shop(){
$this->assign('message','很抱歉,您要找的店铺已经找不到了~');
return $this->fetch('error_msg');
}
public function message(){
$code = input('code');
if(!empty($code) && session($code)!=''){
$this->assign('message',session($code));
}else{
$this->assign('message','操作错误,请联系商城管理员');
}
return $this->fetch('error_msg');
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Favorites as M;
/**
* ============================================================================
* 收藏控制器
*/
class Favorites extends Base{
protected $beforeActionList = ['checkAuth'];
/**
* 关注的商品
*/
public function goods(){
return $this->fetch('users/favorites/list_goods');
}
/**
* 关注的店铺
*/
public function shops(){
return $this->fetch('users/favorites/list_shops');
}
/**
* 关注的商品列表
*/
public function listGoodsQuery(){
$m = new M();
$data = $m->listGoodsQuery();
return WSTReturn("", 1,$data);
}
/**
* 关注的店铺列表
*/
public function listShopQuery(){
$m = new M();
$data = $m->listShopQuery();
return WSTReturn("", 1,$data);
}
/**
* 取消关注
*/
public function cancel(){
$m = new M();
$rs = $m->del();
return $rs;
}
/**
* 增加关注
*/
public function add(){
$m = new M();
$rs = $m->add();
return $rs;
}
}

View File

@ -0,0 +1,706 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\Goods as M;
use wstmart\common\model\Goods as CM;
/**
* ============================================================================
* 商品控制器
*/
class Goods extends Base{
protected $beforeActionList = [
'checkShopAuth' => ['except'=>'search,lists,detail,historybygoods,contrastgoods,contrastdel,contrast']
];
/**
* 批量删除商品
*/
public function batchDel(){
$m = new M();
return $m->batchDel();
}
/**
* 修改商品库存/价格
*/
public function editGoodsBase(){
$m = new M();
return $m->editGoodsBase();
}
/**
* 修改商品状态
*/
public function changSaleStatus(){
$m = new M();
return $m->changSaleStatus();
}
/**
* 修改商品店长推荐状态
*/
public function changStoreRecom(){
$m = new M();
return $m->changStoreRecom();
}
/**
* 批量修改商品状态 新品/精品/热销/推荐
*/
public function changeGoodsStatus(){
$m = new M();
return $m->changeGoodsStatus();
}
/**
* 批量修改商品状态 店长推荐
*/
public function changeStoreStatus(){
$m = new M();
return $m->changeStoreStatus();
}
/**
* 批量上(下)架
*/
public function changeSale(){
$m = new M();
return $m->changeSale();
}
/**
* 上架商品列表
*/
public function sale(){
return $this->fetch('shops/goods/list_sale');
}
/**
* 获取上架商品列表
*/
public function saleByPage(){
$m = new M();
$rs = $m->saleByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 仓库中商品
*/
public function store(){
return $this->fetch('shops/goods/list_store');
}
/**
* 审核中的商品
*/
public function audit(){
return $this->fetch('shops/goods/list_audit');
}
/**
* 获取审核中的商品
*/
public function auditByPage(){
$m = new M();
$rs = $m->auditByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 获取仓库中的商品
*/
public function storeByPage(){
$m = new M();
$rs = $m->storeByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 违规商品
*/
public function illegal(){
return $this->fetch('shops/goods/list_illegal');
}
/*
* 设置商品特定价格
* */
public function limitPrice(){
$shopId=(int)session('WST_USER.shopId');
$where['shopId'] = $shopId;
$where['goodsStatus'] = 1;
$where['dataFlag'] = 1;
$where['isSale'] = 1;
if (Request()->isPost()) {
$goodsType = input('goodsType');
if ($goodsType != '') $where['goodsType'] = (int)$goodsType;
$c1Id = (int)input('cat1');
$c2Id = (int)input('cat2');
$goodsName = input('goodsName');
if ($goodsName != '') {
$where['goodsName'] = ['like', "%$goodsName%"];
}
if ($c2Id != 0 && $c1Id != 0) {
$where['shopCatId2'] = $c2Id;
} else if ($c1Id != 0) {
$where['shopCatId1'] = $c1Id;
}
}
$lists=db('goods')->where($where)->field('goodsId,goodsName,goodsType')->select();
//dump($lists);
if (Request()->isAjax()) {
//dump($lists);
exit(json_encode(WSTReturn('',1,$lists)));
}
$this->assign('lists',$lists);
return $this->fetch('shops/goods/list_limitprice');
}
//获取商品货号
public function getGoodsProduct(){
$goodsId = (int)input('goodsId');
$res['specs'] = db('goods_specs')->where(['goodsId'=>$goodsId])->field('productNo,specIds')->select();
$res['goods'] = db('goods')->where(['goodsId'=>$goodsId])->field('marketPrice')->find();
// dump($res);die;
exit(json_encode($res));
}
//获取商品规格
public function getGoodsSpecs(){
$productNo = input('productNo');
$res = db('goods_specs')->where(['productNo'=>$productNo])->field('specIds,marketPrice')->find();
$specs = explode(':',$res['specIds']);
$data = db('spec_items')->where(['itemId'=>['in',$specs]])->select();
$rs['itemName'] = implode(',',array_column($data,'itemName'));
$rs['marketPrice'] = $res['marketPrice'];
exit(json_encode($rs));
}
/**
* 获取违规的商品
*/
public function illegalByPage(){
$m = new M();
$rs = $m->illegalByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 获取已设置限时价格的商品
*/
public function limitPriceByPage(){
$m = new M();
$rs = $m->limitPriceByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 获取指定显示价格的商品的商品
*/
public function getLimitGoods(){
$m = new M();
$rs = $m->getLimitGoods();
return $rs;
}
/**
* 跳去新增限时价格商品页面
*/
public function addLimitGoods(){
$m = new M();
$rs = $m->addLimitGoods();
return $rs;
}
/**
* 跳去编辑限时价格商品页面
*/
public function editLimitGoods(){
$m = new M();
$rs = $m->editLimitGoods();
return $rs;
}
/**
* 删除显示价格商品
*/
public function delLimitGoods(){
$m = new M();
$rs = $m->delLimitGoods();
return $rs;
}
/**
* 跳去新增页面
*/
public function add(){
$m = new M();
$object = $m->getEModel('goods');
$shopId=(int)session('WST_USER.shopId');
// $object['pay']=db('shop_pay')->where(['shopId'=>$shopId,'status'=>1])->find();
// $object['isEct']=0;
$object['ectPayRatio'] = db('payments')->where(['payCode'=>'ect'])->value('payRatio');
$object['goodsSn'] = WSTGoodsNo();
$object['productNo'] = WSTGoodsNo();
$object['goodsImg'] = WSTConf('CONF.goodsLogo');
$object['ectPay']=0;//db('goods')->alias('g')->join('goods_ectpay ge','ge.goodsId=g.goodsId','left')->value('ectPay');
$object['alone'] =0;
$object['basicsMoney'] = 0;
$aloneShop = db('alone_shops')->alias('as')->join('__SHOPS__ s','as.shopId=s.shopId')->where(['as.dataFlag'=>'1','as.shopId'=>$shopId])->value('as.shopId');
if($aloneShop){
$object['alone'] =1;
}
//dump($object);
$data = ['object'=>$object,'src'=>'add'];
return $this->fetch('shops/goods/edit',$data);
}
/**
* 新增商品
*/
public function toAdd(){
$m = new M();
return $m->add();
}
/**
* 跳去编辑页面
*/
public function edit(){
$m = new M();
$object = $m->getById(input('get.id'));
$shopId=(int)session('WST_USER.shopId');
// $object['pay']=db('shop_pay')->where(['shopId'=>$shopId,'status'=>1])->find();
// //$object['pay']=1;
// if($object['pay']){
// $object['isEct']=db('goods_pay')->where('goodsId',$object['goodsId'])->value('ectPay');
// //$object['isOnline']=db('goods_pay')->where('goodsId',$object['goodsId'])->value('onlinePay');
// }
$object['ectPayRatio'] = db('payments')->where(['payCode'=>'ect'])->value('payRatio');
if($object['goodsImg']=='')$object['goodsImg'] = WSTConf('CONF.goodsLogo');
$object['ectPay']=0;
if($object['basicsMoney'] == '') $object['basicsMoney'] = 0;
$object['alone'] =0;
$aloneShop = db('alone_shops')->alias('as')->join('__SHOPS__ s','as.shopId=s.shopId')->where(['as.dataFlag'=>'1','as.shopId'=>$shopId])->value('as.shopId');
if($aloneShop){
$object['alone'] =1;
}
$data = ['object'=>$object,'src'=>input('src')];
return $this->fetch('shops/goods/edit',$data);
}
/**
* 编辑商品
*/
public function toEdit(){
$m = new M();
return $m->edit();
}
/**
* 删除商品
*/
public function del(){
$m = new M();
return $m->del();
}
/**
* 获取商品规格属性
*/
public function getSpecAttrs(){
$m = new M();
return $m->getSpecAttrs();
}
/**
* 进行商品搜索
*/
public function search(){
//获取商品记录
$m = new M();
$data = [];
$data['isStock'] = Input('isStock/d');
$data['isNew'] = Input('isNew/d');
$data['isFreeShipping'] = input('isFreeShipping/d');
$data['orderBy'] = Input('orderBy/d');
$data['order'] = Input('order/d',1);
$data['keyword'] = input('keyword');
$data['sprice'] = Input('sprice/d');
$data['eprice'] = Input('eprice/d');
$data['areaId'] = (int)Input('areaId');
$aModel = model('home/areas');
// 获取地区
$data['area1'] = $data['area2'] = $data['area3'] = $aModel->listQuery(); // 省级
// 如果有筛选地区 获取上级地区信息
if($data['areaId']!==0){
$areaIds = $aModel->getParentIs($data['areaId']);
/*
2 => int 440000
1 => int 440100
0 => int 440106
*/
$selectArea = [];
$areaName = '';
foreach($areaIds as $k=>$v){
$a = $aModel->getById($v);
$areaName .=$a['areaName'];
$selectArea[] = $a;
}
// 地区完整名称
$selectArea['areaName'] = $areaName;
// 当前选择的地区
$data['areaInfo'] = $selectArea;
$data['area2'] = $aModel->listQuery($areaIds[2]); // 广东的下级
$data['area3'] = $aModel->listQuery($areaIds[1]); // 广州的下级
}
$data['goodsPage'] = $m->pageQuery();
return $this->fetch("goods_search",$data);
}
/**
* 获取商品列表
*/
public function lists(){
$catId = Input('cat/d');
$goodsCatIds = model('GoodsCats')->getParentIs($catId);
reset($goodsCatIds);
//填充参数
$data = [];
$data['catId'] = $catId;
$data['isStock'] = Input('isStock/d');
$data['isNew'] = Input('isNew/d');
$data['isFreeShipping'] = input('isFreeShipping/d');
$data['orderBy'] = Input('orderBy/d');
$data['order'] = Input('order/d',1);
$data['sprice'] = Input('sprice');
$data['eprice'] = Input('eprice');
$data['attrs'] = [];
$data['areaId'] = (int)Input('areaId');
$aModel = model('home/areas');
// 获取地区
$data['area1'] = $data['area2'] = $data['area3'] = $aModel->listQuery(); // 省级
// 如果有筛选地区 获取上级地区信息
if($data['areaId']!==0){
$areaIds = $aModel->getParentIs($data['areaId']);
/*
2 => int 440000
1 => int 440100
0 => int 440106
*/
$selectArea = [];
$areaName = '';
foreach($areaIds as $k=>$v){
$a = $aModel->getById($v);
$areaName .=$a['areaName'];
$selectArea[] = $a;
}
// 地区完整名称
$selectArea['areaName'] = $areaName;
// 当前选择的地区
$data['areaInfo'] = $selectArea;
$data['area2'] = $aModel->listQuery($areaIds[2]); // 广东的下级
$data['area3'] = $aModel->listQuery($areaIds[1]); // 广州的下级
}
$vs = input('vs');
$vs = ($vs!='')?explode(',',$vs):[];
foreach ($vs as $key => $v){
if($v=='' || $v==0)continue;
$v = (int)$v;
$data['attrs']['v_'.$v] = input('v_'.$v);
}
$data['vs'] = $vs;
$brandIds = Input('brand');
$bgIds = [];// 品牌下的商品Id
if(!empty($vs)){
// 存在筛选条件,取出符合该条件的商品id,根据商品id获取可选品牌
$goodsId = model('goods')->filterByAttributes();
$data['brandFilter'] = model('Brands')->canChoseBrands($goodsId);
}else{
// 取出分类下包含商品的品牌
$data['brandFilter'] = model('Brands')->goodsListQuery((int)current($goodsCatIds));
}
if(!empty($brandIds))$bgIds = model('Brands')->getGoodsIds($brandIds);
$data['price'] = Input('price');
//封装当前选中的值
$selector = [];
//处理品牌
$brandIds = explode(',',$brandIds);
$bIds = $brandNames = [];
foreach($brandIds as $bId){
if($bId>0){
foreach ($data['brandFilter'] as $key =>$v){
if($v['brandId']==$bId){
array_push($bIds, $v['brandId']);
array_push($brandNames, $v['brandName']);
}
}
$selector[] = ['id'=>join(',',$bIds),'type'=>'brand','label'=>"品牌","val"=>join('、',$brandNames)];
}
}
// 当前是否有品牌筛选
if(!empty($selector)){
$_s[] = $selector[count($selector)-1];
$selector = $_s;
unset($data['brandFilter']);
}
$data['brandId'] = Input('brand');
//处理价格
if($data['sprice']!='' && $data['eprice']!=''){
$selector[] = ['id'=>0,'type'=>'price','label'=>"价格","val"=>$data['sprice']."-".$data['eprice']];
}
if($data['sprice']!='' && $data['eprice']==''){
$selector[] = ['id'=>0,'type'=>'price','label'=>"价格","val"=>$data['sprice']."以上"];
}
if($data['sprice']=='' && $data['eprice']!=''){
$selector[] = ['id'=>0,'type'=>'price','label'=>"价格","val"=>"0-".$data['eprice']];
}
//处理已选属性
$goodsFilter = model('Attributes')->listQueryByFilter($catId);
$ngoodsFilter = [];
if(!empty($vs)){
// 存在筛选条件,取出符合该条件的商品id,根据商品id获取可选属性进行拼凑
$goodsId = model('goods')->filterByAttributes();
// 如果同时有筛选品牌,则与品牌下的商品Id取交集
if(!empty($bgIds))$goodsId = array_intersect($bgIds,$goodsId);
$attrs = model('Attributes')->getAttribute($goodsId);
// 去除已选择属性
foreach ($attrs as $key =>$v){
if(!in_array($v['attrId'],$vs))$ngoodsFilter[] = $v;
}
}else{
if(!empty($bgIds))$goodsFilter = model('Attributes')->getAttribute($bgIds);// 存在品牌筛选
// 当前无筛选条件,取出分类下所有属性
foreach ($goodsFilter as $key =>$v){
if(!in_array($v['attrId'],$vs))$ngoodsFilter[] = $v;
}
}
if(count($vs)>0){
$_vv = [];
$_attrArr = [];
foreach ($goodsFilter as $key =>$v){
if(in_array($v['attrId'],$vs)){
foreach ($v['attrVal'] as $key2 =>$vv){
if(strstr(input('v_'.$v['attrId']),$vv)!==false){
array_push($_vv, $vv);
$_attrArr[$v['attrId']]['attrName'] = $v['attrName'];
$_attrArr[$v['attrId']]['val'] = $_vv;
}
}
$_vv = [];
}
}
foreach($_attrArr as $k1=>$v1){
$selector[] = ['id'=>$k1,'type'=>'v_'.$k1,'label'=>$v1['attrName'],"val"=>join('、',$v1['val'])];
}
}
$data['selector'] = $selector;
$data['goodsFilter'] = $ngoodsFilter;
//获取商品记录
$m = new M();
$data['priceGrade'] = $m->getPriceGrade($goodsCatIds);
$data['goodsPage'] = $m->pageQuery($goodsCatIds);
$catPaths = model('goodsCats')->getParentNames($catId);
$data['catNamePath'] = '全部商品分类';
if(!empty($catPaths))$data['catNamePath'] = implode(' - ',$catPaths);
// 商品分类下级
$where = ['parentId'=>0,'dataFlag'=>1];
if($catId!='')$where['parentId']=$catId;
$goodsCats = model('goodsCats')->field('catId,catName')->where($where)->select();
$this->assign('goodsCats',$goodsCats);
return $this->fetch("goods_list",$data);
}
/**
* 查看商品详情
*/
public function detail(){
$m = new M();
$goods = $m->getBySale(input('id/d',0));
$key=input('key');
if(!empty($goods)){
//判断是否药品
$goods_cat=strpos($goods['goodsCatIdPath'],'389');
if($goods_cat!==false && $key==''){
return $this->fetch("error_lost");
}
if((int)session('WST_USER.userId')!=""){
$history_data['userId']=(int)session('WST_USER.userId');
$history_data['goodsId']=$goods['goodsId'];
$history_data['path']='1';
$history_data['create_time']=time();
$result=db('page_view')->insert($history_data);
}
$history = cookie("history_goods");
$history = is_array($history)?$history:[];
array_unshift($history, (string)$goods['goodsId']);
$history = array_values(array_unique($history));
if(!empty($history)){
cookie("history_goods",$history,25920000);
}
// 商品详情延迟加载
$goods['goodsDesc']=htmlspecialchars_decode($goods['goodsDesc']);
//修改匹配规则 适应oss 地址 mark 20180615 by zl
// $rule = '/<img src="\/(upload.*?)"/';
$rule = '/<img src=".*?\/(upload.*?)"/';
preg_match_all($rule, $goods['goodsDesc'], $images);
foreach($images[0] as $k=>$v){
//mark by cheng商品详情换成远程oss图片20180313
//$goods['goodsDesc'] = str_replace($v, "<img class='goodsImg' data-original=\"__ROOT__/".WSTImg($images[1][$k],3)."\"", $goods['goodsDesc']);
$goods['goodsDesc'] = str_replace($v, "<img class='goodsImg' data-original=\"__IMGURL__/".WSTImg($images[1][$k],0)."\"", $goods['goodsDesc']);
}
hook('afterGetGoods',['params'=>&$goods]);
$goods['is_seckilling']=isset($goods['is_seckilling'])?$goods['is_seckilling']:0;
$this->assign('goods',$goods);
$this->assign('shop',$goods['shop']);
return $this->fetch("goods_detail");
}else{
return $this->fetch("error_lost");
}
}
/**
* 预警库存
*/
public function stockwarnbypage(){
return $this->fetch("shops/stockwarn/list");
}
/**
* 获取预警库存列表
*/
public function stockByPage(){
$m = new M();
$rs = $m->stockByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 修改预警库存
*/
public function editwarnStock(){
$m = new M();
return $m->editwarnStock();
}
/**
* 获取商品浏览记录
*/
public function historyByGoods(){
$rs = model('Tags')->historyByGoods(8);
return WSTReturn('',1,$rs);
}
/**
* 记录对比商品
*/
public function contrastGoods(){
$id = (int)input('post.id');
$contras = cookie("contras_goods");
if($id>0){
$m = new M();
$goods = $m->getBySale($id);
$catId = explode('_',$goods['goodsCatIdPath']);
$catId = $catId[0];
if(isset($contras['catId']) && $catId!=$contras['catId'])return WSTReturn('请选择同分类对比',-1);
if(isset($contras['list']) && count($contras['list'])>3)return WSTReturn('对比栏已满',-1);
if(!isset($contras['catId']))$contras['catId'] = $catId;
$contras['list'][$id] = $id;
cookie("contras_goods",$contras,25920000);
}
if(isset($contras['list'])){
$m = new M();
$list = [];
foreach($contras['list'] as $k=>$v){
$list[] = $m->getBySale($v);
}
return WSTReturn('',1,$list);
}else{
return WSTReturn('',1);
}
}
/**
* 删除对比商品
*/
public function contrastDel(){
$id = (int)input('post.id');
$contras = cookie("contras_goods");
if($id>0 && isset($contras['list'])){
unset($contras['list'][$id]);
cookie("contras_goods",$contras,25920000);
}else{
cookie("contras_goods", null);
}
return WSTReturn('删除成功',1);
}
/**
* 商品对比
*/
public function contrast(){
$contras = cookie("contras_goods");
$list = [];
$list = $lists= $saleSpec = $shop = $score = $brand = $spec = [];
if(isset($contras['list'])){
$m = new M();
foreach($contras['list'] as $key=>$value){
$dara = $m->getBySale($value);
if(isset($dara['saleSpec'])){
foreach($dara['saleSpec'] as $ks=>$vs){
if($vs['isDefault']==1){
$dara['defaultSpec'] = $vs;
$dara['defaultSpec']['ids'] = explode(':',$ks);
}
}
$saleSpec[$value] = $dara['saleSpec'];
}
$list[] = $dara;
}
//第一个商品信息
$goods = $list[0];
//对比处理
$shops['identical'] = $scores['identical'] = $brands['identical'] = 1;
foreach($list as $k=>$v){
$shop[$v['goodsId']] = $v['shop']['shopName'];
if($goods['shop']['shopId']!=$v['shop']['shopId'])$shops['identical'] = 0;
$score[$v['goodsId']] = $v['scores']['totalScores'];
if($goods['scores']['totalScores']!=$v['scores']['totalScores'])$scores['identical'] = 0;
$brand[$v['goodsId']] = $v['brandName'];
if($goods['brandId']!=$v['brandId'])$brands['identical'] = 0;
if(isset($v['spec'])){
foreach($v['spec'] as $k2=>$v2){
$spec[$k2]['identical'] = 0;
$spec[$k2]['type'] = 'spec';
$spec[$k2]['name'] = $v2['name'];
$spec[$k2]['catId'] = $k2;
foreach($v2['list'] as $ks22=>$vs22){
$v['spec'][$k2]['list'][$ks22]['isDefault'] = (in_array($vs22['itemId'],$v['defaultSpec']['ids']))?1:0;
}
$spec[$k2]['info'][$v['goodsId']] = $v['spec'][$k2];
}
}
}
$shops['name'] = '店铺';
$shops['type'] = 'shop';
$shops['info'] = $shop;
$lists[] = $shops;
$scores['name'] = '商品评分';
$scores['type'] = 'score';
$scores['info'] = $score;
$lists[] = $scores;
$brands['name'] = '品牌';
$brands['type'] = 'brand';
$brands['info'] = $brand;
$lists[] = $brands;
foreach($spec as $k3=>$v3){
$lists[] = $v3;
}
}
$data['list'] = $list;
$data['lists'] = $lists;
$data['saleSpec'] = $saleSpec;
$this->assign('data',$data);
return $this->fetch("goods_contrast");
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\GoodsAppraises as M;
/**
* ============================================================================
* 评价控制器
*/
class GoodsAppraises extends Base{
protected $beforeActionList = [
'checkAuth' => ['except'=>'userappraise,getbyid'],
'checkShopAuth'=>['only'=>'index,querybypage,shopreply']
];
/**
* 获取评价列表 商家
*/
public function index(){
return $this->fetch('shops/goodsappraises/list');
}
/**
* 获取评价列表 用户
*/
public function myAppraise(){
return $this->fetch('users/orders/appraise_manage');
}
// 获取评价列表 商家
public function queryByPage(){
$m = new M();
return $m->queryByPage();
}
// 获取评价列表 用户
public function userAppraise(){
$m = new M();
return $m->userAppraise();
}
/**
* 添加评价
*/
public function add(){
$m = new M();
$rs = $m->add();
return $rs;
}
/**
* 根据商品id取评论
*/
public function getById(){
$m = new M();
$rs = $m->getById();
return $rs;
}
/**
* 商家回复评价
*/
public function shopReply(){
$m = new M();
return $m->shopReply();
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\GoodsCats as M;
/**
* ============================================================================
* 商品分类控制器
*/
class Goodscats extends Base{
/**
* 获取列表
*/
public function listQuery(){
$m = new M();
$rs = $m->listQuery(input('parentId/d',0));
return WSTReturn("", 1,$rs);
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\GoodsConsult as M;
/**
* ============================================================================
* 商品咨询控制器
*/
class GoodsConsult extends Base{
protected $beforeActionList = [
'checkShopAuth'=>['only'=>'pageQuery,shopReplyConsult,reply']
];
/**
* 根据商品id获取商品咨询
*/
public function listQuery(){
$m = new M();
$rs = $m->listQuery();
return $rs;
}
/**
* 新增
*/
public function add(){
$m = new M();
return $m->add();
}
/**
* 根据店铺id获取商品咨询
*/
public function pageQuery(){
$m = new M();
$rs = $m->pageQuery();
return $rs;
}
/**
* 获取商品咨询 商家
*/
public function shopReplyConsult(){
return $this->fetch('shops/goodsconsult/list');
}
/**
* 商家回复
*/
public function reply(){
$m = new M();
return $m->reply();
}
/**
* 用户-商品咨询
*/
public function myConsult(){
return $this->fetch('users/my_consult');
}
/**
* 用户-商品咨询列表查询
*/
public function myConsultByPage(){
$m = new M();
return $m->myConsultByPage();
}
}

View File

@ -0,0 +1,81 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\GoodsVirtuals as M;
/**
* ============================================================================
* 虚拟商品卡券控制器
*/
class Goodsvirtuals extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 查看虚拟商品库存
*/
public function stock(){
$src = input('src','sale');
if(!in_array($src,['sale','audit','store','stockWarnByPage','illegal']))$src = 'sale';
$this->assign('src',$src);
$this->assign('id',(int)input('id'));
return $this->fetch("shops/goodsvirtuals/list");
}
/**
* 获取虚拟商品库存列表
*/
public function stockByPage(){
$m = new M();
$rs = $m->stockByPage();
$rs['status'] = 1;
return $rs;
}
/**
* 跳去新增页
*/
public function toAdd(){
$this->assign('object',['cardNo'=>'','cardPwd'=>'','id'=>0]);
return $this->fetch('shops/goodsvirtuals/edit');
}
/**
* 跳去编辑页
*/
public function toEdit(){
$m = new M();
$rs = $m->get((int)input('id'));
$this->assign('object',$rs);
return $this->fetch('shops/goodsvirtuals/edit');
}
/**
* 生成卡券
*/
public function add(){
$m = new M();
$rs = $m->add();
return $rs;
}
/**
* 删除
*/
public function del(){
$m = new M();
$rs = $m->del();
return $rs;
}
/**
* 编辑
*/
public function edit(){
$m = new M();
$rs = $m->edit();
return $rs;
}
/**
* 导入卡券
*/
public function importCards(){
$rs = WSTUploadFile();
if(json_decode($rs)->status==1){
$m = new M();
$rss = $m->importCards($rs);
return $rss;
}
return $rs;
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
*/
class Helpcenter extends Base{
public function index(){
return $this->view();
}
public function view(){
//获取左侧列表
$m = model('home/Articles');
$list = $m->helpList();
$data = $m->getHelpById();
$this->assign('data',$data);
$this->assign('list',$list);
//面包屑导航
$bcNav = [];
if(!empty($data)){
$bcNav = $this->bcNav();
}
$this->assign('bcNav',$bcNav);
return $this->fetch('articles/help');
}
/**
* 记录解决情况
*/
public function recordSolve(){
$m = model('home/Articles');
return $m->recordSolve();
}
/**
* 面包屑导航
*/
public function bcNav(){
$m = model('home/Articles');
return $m->bcNav();
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\Imports as M;
/**
* ============================================================================
* 默认控制器
*/
class Imports extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 数据导入首页
*/
public function index(){
return $this->fetch('shops/import');
}
/**
* 上传商品数据
*/
public function importGoods(){
$rs = WSTUploadFile();
if(json_decode($rs)->status==1){
$m = new M();
$rss = $m->importGoods($rs);
return $rss;
}
return $rs;
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 默认控制器
*/
class Index extends Base{
protected $beforeActionList = [
'checkAuth' => ['only'=>'getsysmessages']
];
public function index(){
$categorys = model('GoodsCats')->getFloors();
$this->assign('floors',$categorys);
$this->assign('hideCategory',1);
// 店铺街数据
$shopStreet = model('shops')->indexShopQuery();
$this->assign('shopStreet',$shopStreet);
//首页优惠券数据
$m = new \addons\hyhcouponrec\model\Hyhcouponrec();
$indexCouponsList = $m->indexCouponsList();
//$indexCouponsList = model('/addons/hyhcouponrec/mode/hyhcouponrec')->indexCouponsList();
$this->assign('indexCouponsList',$indexCouponsList);
// dump(coupon_list());
return $this->fetch('index');
}
/**
* 保存目录ID
*/
public function getMenuSession(){
$menuId = input("post.menuId");
$menuType = session('WST_USER.loginTarget');
session('WST_MENUID3'.$menuType,$menuId);
}
/**
* 获取用户信息
*/
public function getSysMessages(){
$rs = model('Systems')->getSysMessages();
return $rs;
}
/**
* 定位菜单以及跳转页面
*/
public function position(){
$menuId = (int)input("post.menuId");
$menuType = ((int)input("post.menuType")==1)?1:0;
$menus = model('HomeMenus')->getParentId($menuId);
session('WST_MENID'.$menus['menuType'],$menus['parentId']);
session('WST_MENUID3'.$menuType,$menuId);
}
/**
* 转换url
*/
public function transfor(){
$data = input('param.');
$url = $data['url'];
unset($data['url']);
echo Url($url,$data);
}
/**
* 保存url
*/
public function currenturl(){
session('WST_HO_CURRENTURL',input('url'));
return WSTReturn("", 1);
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Informs as M;
/**
* ============================================================================
* 订单投诉控制器
*/
class Informs extends Base{
protected $beforeActionList = [
'checkAuth'=>['only'=>'index,queryusercomplainbypage,complain,savecomplain,getusercomplaindetail'],
'checkShopAuth'=>['only'=>'shopcomplain,queryshopcomplainbypage,getshopcomplaindetail,respond,saverespond']
];
/******************************** 用户 ******************************************/
/**
* 查看举报列表
*/
public function index(){
return $this->fetch('users/informs/list_inform');
}
/**
* 获取用户举报列表
*/
public function queryUserInformPage(){
$m = model('Informs');
return $m->queryUserInformByPage();
}
/**
* 商品举报页面
*/
public function inform(){
$m = new M();
$data = $m->inform();
if($data['status'] == 1){
$this->assign("data",$data);
return $this->fetch("users/informs/informs");
}else{
$this->assign("message",$data['msg']);
return $this->fetch("error_msg");
}
}
/**
* 保存举报信息
*/
public function saveInform(){
return model('Informs')->saveInform();
}
/**
* 用户查举报详情
*/
public function getUserInformDetail(){
$data = model('Informs')->getUserInformDetail(0);
$this->assign("data",$data);
return $this->fetch("users/informs/inform_detail");
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Invoices as M;
/**
* ============================================================================
* 发票信息控制器
*/
class Invoices extends Base{
/**
*
*/
public function index(){
$m = new M();
$data = $m->pageQuery();
$this->assign('invoiceId',(int)input('invoiceId'));
$this->assign('isInvoice',(int)input('isInvoice'));
$this->assign('data',$data);
return $this->fetch('invoices');
}
/**
* 查询
*/
public function pageQuery(){
$m = new M();
return $m->pageQuery();
}
/**
* 新增
*/
public function add(){
$m = new M();
return $m->add();
}
/**
* 修改
*/
public function edit(){
$m = new M();
return $m->edit();
}
/**
* 删除
*/
public function del(){
$m = new M();
return $m->del();
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\LogMoneys as M;
/**
* ============================================================================
* 资金流水控制器
*/
class Logmoneys extends Base{
protected $beforeActionList = [
'checkAuth'=>['only'=>'usermoneys,pageuserquery,touserrecharge'],
'checkShopAuth'=>['only'=>'shopmoneys,pageshopquery,torecharge']
];
/**
* 查看用户资金流水
*/
public function usermoneys(){
$rs = model('Users')->getFieldsById((int)session('WST_USER.userId'),['lockMoney','userMoney','rechargeMoney']);
$this->assign('object',$rs);
return $this->fetch('users/logmoneys/list');
}
/**
* 查看商户资金流水
*/
public function shopmoneys(){
$shopId = (int)session('WST_USER.shopId');
$rs = model('Shops')->getFieldsById($shopId,['lockMoney','shopMoney','noSettledOrderFee','paymentMoney']);
$rs['deposit'] = db('shops_deposit')->where(['shopId'=>$shopId])->field('payDeposit,cashDeposit,isFinish')->find();
$this->assign('object',$rs);
return $this->fetch('shops/logmoneys/list');
}
/**
* 获取用户数据
*/
public function pageUserQuery(){
$userId = (int)session('WST_USER.userId');
$data = model('logMoneys')->pageQuery(0,$userId);
return WSTReturn("", 1,$data);
}
/**
* 获取商家数据
*/
public function pageShopQuery(){
$shopId = (int)session('WST_USER.shopId');
$data = model('logMoneys')->pageQuery(1,$shopId);
return WSTReturn("", 1,$data);
}
/**
* 获取商家质保金流水
*/
public function pageShopDeposit(){
$shopId = (int)session('WST_USER.shopId');
$data = model('logMoneys')->pageDeposit(1,$shopId);
return WSTReturn("", 1,$data);
}
/**
* 充值[商家]
*/
public function toRecharge(){
$payments = model('common/payments')->recharePayments('1');
$this->assign('payments',$payments);
$chargeItems = model('common/ChargeItems')->queryList();
$this->assign('chargeItems',$chargeItems);
return $this->fetch('shops/recharge/pay_step1');
}
/**
* 充值[用户]
*/
public function toUserRecharge(){
$payments = model('common/payments')->recharePayments('1');
$this->assign('payments',$payments);
$chargeItems = model('common/ChargeItems')->queryList();
$this->assign('chargeItems',$chargeItems);
return $this->fetch('users/recharge/pay_step1');
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 商城消息控制器
*/
class Messages extends Base{
protected $beforeActionList = ['checkAuth'];
/**
* 查看商城消息
*/
public function index(){
return $this->fetch('users/messages/list');
}
/**
* 查看商城消息
*/
public function shopMessage(){
return $this->fetch('shops/messages/list');
}
/**
* 获取数据
*/
public function pageQuery(){
$data = model('Messages')->pageQuery();
return WSTReturn("", 1,$data);
}
/**
* 查看完整商城消息
*/
public function showMsg(){
$data = model('Messages')->getById();
return $this->fetch('users/messages/show',['data'=>$data]);
}
public function showShopMsg(){
$data = model('Messages')->getById();
return $this->fetch('shops/messages/show',['data'=>$data]);
}
/**
* 删除
*/
public function del(){
$m = model('Home/Messages');
$rs = $m->del();
return $rs;
}
/**
* 批量删除
*/
public function batchDel(){
$m = model('Home/Messages');
$rs = $m->batchDel();
return $rs;
}
/**
* 标记为已读
*/
public function batchRead(){
$m = model('Home/Messages');
$rs = $m->batchRead();
return $rs;
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
*/
class News extends Base{
/**
* 根据分类id获取文章列表
*/
public function nList(){
$m = model('home/articles');
$pageObj = $m->nList();
$news = $pageObj->toArray();
// 分页页码
$page = $pageObj->render();
$this->assign('page',$page);
//获取左侧列表
$leftList = $m->NewsList();
$this->assign('list',$leftList);
$this->assign('newsList',$news['Rows']);
$this->assign('catId',(int)input('catId'));
//面包屑导航
$bcNav = $this->bcNav();
// 防止用户取出帮助中心分类
foreach($bcNav as $k=>$v){
if($v['catId']==7){
$bcNav = [];
break;
}
}
// 获取title
$currTitle = '';
foreach($bcNav as $k=>$v){
if($v['catId']==(int)input('catId'))$currTitle = $v['catName'];
}
$this->assign('title',$currTitle);
$this->assign('bcNav',$bcNav);
// 防止没有数据时报错
if(empty($bcNav))$this->redirect('home/News/view');
return $this->fetch('articles/news_list');
}
public function view(){
//获取左侧列表
$m = model('home/Articles');
$list = $m->NewsList();
//当前分类id
$content = $m->getNewsById();
if(63 == $content['catId']) $this->error('请付费后查看!','/newscats-63.html');
$this->assign('catId',(int)$content['catId']);
$this->assign('list',$list);
$this->assign('content',$content);
//面包屑导航
$bcNav = [];
if(!empty($content)){
$bcNav = $this->bcNav();
}
$this->assign('bcNav',$bcNav);
if((int)input('id')==0){
// 资讯列表下的新闻
$pageObj = $m->getArticles();
$news = $pageObj->toArray();
// 分页页码
$page = $pageObj->render();
$this->assign('page',$page);
$this->assign('index',$news['Rows']);
}
return $this->fetch('articles/news_view');
}
public function bcNav(){
$m = model('home/Articles');
return $m->bcNav();
}
public function index(){
return $this->view();
}
}

View File

@ -0,0 +1,94 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 订单投诉控制器
*/
class OrderComplains extends Base{
protected $beforeActionList = [
'checkAuth'=>['only'=>'index,queryusercomplainbypage,complain,savecomplain,getusercomplaindetail'],
'checkShopAuth'=>['only'=>'shopcomplain,queryshopcomplainbypage,getshopcomplaindetail,respond,saverespond']
];
/******************************** 用户 ******************************************/
/**
* 查看投诉列表
*/
public function index(){
return $this->fetch('users/orders/list_complain');
}
/**
* 获取用户投诉列表
*/
public function queryUserComplainByPage(){
$m = model('OrderComplains');
return $m->queryUserComplainByPage();
}
/**
* 订单投诉页面
*/
public function complain(){
$data = model('OrderComplains')->getOrderInfo();
$this->assign("data",$data);
return $this->fetch("users/orders/complain");
}
/**
* 保存订单投诉信息
*/
public function saveComplain(){
return model('OrderComplains')->saveComplain();
}
/**
* 用户查投诉详情
*/
public function getUserComplainDetail(){
$data = model('OrderComplains')->getComplainDetail(0);
$this->assign("data",$data);
return $this->fetch("users/orders/complain_detail");
}
/******************************* 商家 ****************************************/
/**
* 商家-查看投诉列表
*/
public function shopComplain(){
return $this->fetch("shops/orders/list_complain");
}
/**
* 获取商家被投诉订单列表
*/
public function queryShopComplainByPage(){
return model('OrderComplains')->queryShopComplainByPage();
}
/**
* 查投诉详情
*/
public function getShopComplainDetail(){
$data = model('OrderComplains')->getComplainDetail(1);
$this->assign("data",$data);
return $this->fetch("shops/orders/complain_detail");
}
/**
* 订单应诉页面
*/
public function respond(){
$data = model('OrderComplains')->getComplainDetail(1);
$this->assign("data",$data);
return $this->fetch("shops/orders/respond");
}
/**
* 保存订单应诉
*/
public function saveRespond(){
return model('OrderComplains')->saveRespond();
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\OrderRefunds as M;
/**
* ============================================================================
* 订单退款控制器
*/
class Orderrefunds extends Base{
protected $beforeActionList = [
'checkAuth'=>['only'=>'refund'],
'checkShopAuth'=>['only'=>'shoprefund']
];
/**
* 用户申请退款
*/
public function refund(){
$m = new M();
$rs = $m->refund();
return $rs;
}
/**
* 商家处理是否同意
*/
public function shopRefund(){
$m = new M();
$rs = $m->shopRefund();
return $rs;
}
}

View File

@ -0,0 +1,415 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Orders as M;
/**
* ============================================================================
* 订单控制器
*/
class Orders extends Base{
/**
* 提交虚拟订单
*/
public function quickSubmit(){
$this->checkAuth();
$m = new M();
$rs = $m->quickSubmit();
return $rs;
}
/**
* 提交订单
*/
public function submit(){
$this->checkAuth();
$m = new M();
$rs = $m->submit();
return $rs;
}
/**
* 订单提交成功
*/
public function succeed(){
$this->checkAuth();
$m = new M();
$rs = $m->getByUnique();
$this->assign('object',$rs);
if(!empty($rs['list'])){
if($rs['payType']==1 && $rs['totalMoney']>0){
$this->assign('orderNo',input("get.orderNo"));
$this->assign('isBatch',(int)input("get.isBatch/d",1));
$this->assign('rs',$rs);
return $this->fetch('order_pay_step1');
}else{
return $this->fetch('order_success');
}
}else{
$this->assign('message','Sorry~您要找的页面丢失了。。。');
return $this->fetch('error_msg');
}
}
/**
* 用户-提醒发货
*/
public function noticeDeliver(){
$m = new M();
return $m->noticeDeliver();
}
/**
* 用户-待付款订单
*/
public function waitPay(){
$this->checkAuth();
return $this->fetch('users/orders/list_wait_pay');
}
/**
* 用户-获取待付款列表
*/
public function waitPayByPage(){
$this->checkAuth();
$m = new M();
$rs = $m->userOrdersByPage(-2);
return WSTReturn("", 1,$rs);
}
/**
* 等待收货
*/
public function waitReceive(){
$this->checkAuth();
return $this->fetch('users/orders/list_wait_receive');
}
/**
* 获取收货款列表
*/
public function waitReceiveByPage(){
$this->checkAuth();
$m = new M();
$rs = $m->userOrdersByPage([0,1]);
return WSTReturn("", 1,$rs);
}
/**
* 用户-待评价
*/
public function waitAppraise(){
$this->checkAuth();
return $this->fetch('users/orders/list_appraise');
}
/**
* 用户-待评价
*/
public function waitAppraiseByPage(){
$this->checkAuth();
$m = new M();
$rs = $m->userOrdersByPage(2,0);
return WSTReturn("", 1,$rs);
}
/**
* 用户-已完成订单
*/
public function finish(){
$this->checkAuth();
return $this->fetch('users/orders/list_finish');
}
/**
* 用户-已完成订单
*/
public function finishByPage(){
$this->checkAuth();
$m = new M();
$rs = $m->userOrdersByPage(2,-1);
return WSTReturn("", 1,$rs);
}
/**
* 用户-加载取消订单页面
*/
public function toCancel(){
$this->checkAuth();
return $this->fetch('users/orders/box_cancel');
}
/**
* 用户取消订单
*/
public function cancellation(){
$this->checkAuth();
$m = new M();
$rs = $m->cancel();
return $rs;
}
/**
* 用户-取消订单列表
*/
public function cancel(){
$this->checkAuth();
return $this->fetch('users/orders/list_cancel');
}
/**
* 用户-获取已取消订单
*/
public function cancelByPage(){
$this->checkAuth();
$m = new M();
$rs = $m->userOrdersByPage(-1);
return WSTReturn("", 1,$rs);
}
/**
* 用户-拒收订单
*/
public function toReject(){
$this->checkAuth();
return $this->fetch('users/orders/box_reject');
}
/**
* 用户拒收订单
*/
public function reject(){
$this->checkAuth();
$m = new M();
$rs = $m->reject();
return $rs;
}
/**
* 用户-申请退款
*/
public function toRefund(){
$this->checkAuth();
$m = new M();
$rs = $m->getMoneyByOrder((int)input('id'));
$this->assign('object',$rs);
return $this->fetch('users/orders/box_refund');
}
/**
* 商家-操作退款
*/
public function toShopRefund(){
$this->checkShopAuth();
$rs = model('OrderRefunds')->getRefundMoneyByOrder((int)input('id'));
$this->assign('object',$rs);
return $this->fetch('shops/orders/box_refund');
}
/**
* 用户-拒收/退款列表
*/
public function abnormal(){
$this->checkAuth();
return $this->fetch('users/orders/list_abnormal');
}
/**
* 获取用户拒收/退款列表
*/
public function abnormalByPage(){
$this->checkAuth();
$m = new M();
$rs = $m->userOrdersByPage([-3]);
return WSTReturn("", 1,$rs);
}
/**
* 等待处理订单
*/
public function waitDelivery(){
$this->checkShopAuth();
$express = model('Express')->listQuery();
$this->assign('express',$express);
return $this->fetch('shops/orders/list_wait_delivery');
}
/**
* 待处理订单
*/
public function waitDeliveryByPage(){
$this->checkShopAuth();
$m = new M();
$rs = $m->shopOrdersByPage([0]);
return WSTReturn("", 1,$rs);
}
/**
* 商家-已发货订单
*/
public function delivered(){
$this->checkShopAuth();
$express = model('Express')->listQuery();
$this->assign('express',$express);
return $this->fetch('shops/orders/list_delivered');
}
/**
* 待处理订单
*/
public function deliveredByPage(){
$this->checkShopAuth();
$m = new M();
$rs = $m->shopOrdersByPage(1);
return WSTReturn("", 1,$rs);
}
/**
* 商家发货
*/
public function deliver(){
$this->checkShopAuth();
$m = new M();
$rs = $m->deliver();
return $rs;
}
/**
* 商家修改快递单号
*/
public function updateDeliver(){
$this->checkShopAuth();
$m = new M();
$res = $m->updateDeliver();
return $res;
}
/**
* 用户收货
*/
public function receive(){
$this->checkAuth();
$m = new M();
$rs = $m->receive();
return $rs;
}
/**
* 用户-延时收货
*/
public function delay(){
$this->checkAuth();
$m = new M();
$rs = $m->delay();
return $rs;
}
/**
* 商家-已完成订单
*/
public function finished(){
$this->checkShopAuth();
$express = model('Express')->listQuery();
return $this->fetch('shops/orders/list_finished');
}
/**
* 商家-已完成订单
*/
public function finishedByPage(){
$this->checkShopAuth();
$m = new M();
$rs = $m->shopOrdersByPage(2);
return WSTReturn("", 1,$rs);
}
/**
* 商家-取消/拒收订单
*/
public function failure(){
$this->checkShopAuth();
return $this->fetch('shops/orders/list_failure');
}
/**
* 商家-取消/拒收订单
*/
public function failureByPage(){
$this->checkShopAuth();
$m = new M();
$rs = $m->shopOrdersByPage([-1,-3]);
return WSTReturn("", 1,$rs);
}
/**
* 获取订单信息方便修改价格
*/
public function getMoneyByOrder(){
$this->checkShopAuth();
$m = new M();
$rs = $m->getMoneyByOrder();
return WSTReturn("", 1,$rs);
}
/**
* 商家修改订单价格
*/
public function editOrderMoney(){
$this->checkShopAuth();
$m = new M();
$rs = $m->editOrderMoney();
return $rs;
}
/**
* 商家-订单详情
*/
public function view(){
$this->checkShopAuth();
$m = new M();
$rs = $m->getByView((int)input('id'));
$this->assign('object',$rs);
return $this->fetch('shops/orders/view');
}
/**
* 订单打印
*/
public function orderPrint(){
$this->checkShopAuth();
$m = new M();
$rs = $m->getByView((int)input('id'));
$this->assign('object',$rs);
return $this->fetch('shops/orders/print');
}
/**
* 用户-订单详情
*/
public function detail(){
$this->checkAuth();
$m = new M();
$rs = $m->getByView((int)input('id'));
$this->assign('object',$rs);
return $this->fetch('users/orders/view');
}
/**
* 用户-评价页
*/
public function orderAppraise(){
$this->checkAuth();
$m = new M();
//根据订单id获取 商品信息跟商品评价
$data = $m->getOrderInfoAndAppr();
$this->assign(['data'=>$data['Rows'],
'count'=>$data['count'],
'alreadys'=>$data['alreadys']
]);
return $this->fetch('users/orders/list_order_appraise');
}
/**
* 设置完成评价
*/
public function complateAppraise($orderId){
$this->checkAuth();
$m = new M();
return $m->complateAppraise($orderId);
}
/**
* 商家-待付款订单
*/
public function waituserPay(){
$this->checkShopAuth();
return $this->fetch('shops/orders/list_wait_pay');
}
/**
* 商家-获取待付款列表
*/
public function waituserPayByPage(){
$this->checkShopAuth();
$m = new M();
$rs = $m->shopOrdersByPage(-2);
return WSTReturn("", 1,$rs);
}
/**
* 导出订单
*/
public function toExport(){
$this->checkShopAuth();
$m = new M();
$rs = $m->toExport();
$this->assign('rs',$rs);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\Reports as M;
/**
* ============================================================================
* 报表控制器
*/
class Reports extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 商品销售排行
*/
public function topSaleGoods(){
$this->assign("startDate",date('Y-m-d',strtotime("-1month")));
$this->assign("endDate",date('Y-m-d'));
return $this->fetch('shops/reports/top_sale_goods');
}
public function getTopSaleGoods(){
$m = new M();
return $m->getTopSaleGoods();
}
/**
* 获取销售额
*/
public function statSales(){
$this->assign("startDate",date('Y-m-d',strtotime("-1month")));
$this->assign("endDate",date('Y-m-d'));
return $this->fetch('shops/reports/stat_sales');
}
public function getStatSales(){
$m = new M();
return $m->getStatSales();
}
/**
* 获取销售订单
*/
public function statOrders(){
$this->assign("startDate",date('Y-m-d',strtotime("-1month")));
$this->assign("endDate",date('Y-m-d'));
return $this->fetch('shops/reports/stat_orders');
}
public function getStatOrders(){
$m = new M();
return $m->getStatOrders();
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\Settlements as M;
/**
* ============================================================================
* 结算控制器
*/
class Settlements extends Base{
protected $beforeActionList = ['checkShopAuth'];
public function index(){
return $this->fetch('shops/settlements/list');
}
/**
* 获取结算单
*/
public function pageQuery(){
$m = new M();
$rs = $m->pageQuery();
return WSTReturn('',1,$rs);
}
/**
* 获取待结算订单
*/
public function pageUnSettledQuery(){
$m = new M();
$rs = $m->pageUnSettledQuery();
return WSTReturn('',1,$rs);
}
/**
* 结算订单
*/
public function settlement(){
$m = new M();
return $m->settlement();
}
/**
* 获取已结算订单
*/
public function pageSettledQuery(){
$m = new M();
$rs = $m->pageSettledQuery();
return WSTReturn('',1,$rs);
}
/**
* 查看结算详情
*/
public function view(){
$m = new M();
$rs = $m->getById();
$this->assign('object',$rs);
return $this->fetch('shops/settlements/view');
}
/**
* 导出订单
*/
public function toExport(){
$m = new M();
$rs = $m->toExport();
$this->assign('rs',$rs);
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\ShopCats as M;
/**
* ============================================================================
* 门店分类控制器
*/
class Shopcats extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 列表
*/
public function index(){
$m = new M();
$list = $m->getCatAndChild(session('WST_USER.shopId'),input('post.parentId/d'));
// mark 添加省份 20180518 by zl
$areas = $m->getAreas();
$this->assign('areas',$areas);
// 判断是否是自营 如果是自营就显示省份
$shopId = (int)session('WST_USER.shopId');;
$this->assign('shopId',$shopId);
// end
$this->assign('list',$list);
return $this->fetch("shops/shopcats/list");
}
/**
* 修改名称
*/
public function editName(){
$m = new M();
$rs = array();
if(input('post.id/d')>0){
$rs = $m->editName();
}
return $rs;
}
/**
* 修改排序
*/
public function editSort(){
$m = new M();
$rs = array();
if(input('post.id/d')>0){
$rs = $m->editSort();
}
return $rs;
}
/**
* 批量保存商品分类
*/
public function batchSaveCats(){
$m = new M();
$rs = $m->batchSaveCats();
return $rs;
}
/**
* 删除操作
*/
public function del(){
$m = new M();
$rs = $m->del();
return $rs;
}
/**
* 列表查询
*/
public function listQuery(){
$m = new M();
$list = $m->listQuery((int)session('WST_USER.shopId'),input('post.parentId/d'));
$rs = array();
$rs['status'] = 1;
$rs['list'] = $list;
return $rs;
}
public function changeCatStatus(){
$m = new M();
$rs = $m->changeCatStatus();
return $rs;
}
/**
* 设置分类特产省份 mark 20180515
*/
public function setSpecial(){
$m = new M();
$rs = $m->setSpecial();
return $rs;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 门店配置控制器
*/
class Shopconfigs extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 店铺设置
*/
public function toShopCfg(){
//获取商品信息
$m = model('ShopConfigs');
$this->assign('object',$m->getShopCfg((int)session('WST_USER.shopId')));
return $this->fetch('shops/shopconfigs/shop_cfg');
}
/**
* 新增/修改 店铺设置
*/
public function editShopCfg(){
$shopId = (int)session('WST_USER.shopId');
$m = model('ShopConfigs');
if($shopId>0){
$rs = $m->editShopCfg($shopId);
}
return $rs;
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\ShopFreights as M;
use wstmart\home\model\Areas;
use wstmart\home\model\Shops;
/**
* ============================================================================
* 运费控制器
*/
class Shopfreights extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 查看运费设置
*/
public function index(){
$shops = new Shops();
$shopId = session('WST_USER.shopId');
$shFreight = $shops->getShopsFreight($shopId);
$this->assign('shFreight',$shFreight);//默认运费
return $this->fetch('shops/freights/list');
}
/**
* 运费列表
*/
public function listProvince(){
$m = new M();
return $m->listProvince();
}
/**
* 编辑
*/
public function edit(){
$m = new M();
$rs = $m->edit();
return $rs;
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\ShopRoles as M;
/**
* ============================================================================
* 门店角色控制器
*/
class Shoproles extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 列表
*/
public function index(){
$m = new M();
$list = $m->pageQuery();
$this->assign('list',$list);
return $this->fetch("shops/shoproles/list");
}
/**
* 查询
*/
public function pageQuery(){
$m = new M();
return $m->pageQuery();
}
/**
* 新增角色
*/
public function add(){
$m = new M();
$object = $m->getEModel('shop_roles');
$data = ['object'=>$object];
return $this->fetch('shops/shoproles/edit',$data);
}
/**
* 新增角色
*/
public function toAdd(){
$m = new M();
return $m->add();
}
/**
* 修改角色
*/
public function edit(){
$m = new M();
$object = $m->getById((int)input('get.id'));
$data = ['object'=>$object];
return $this->fetch('shops/shoproles/edit',$data);
}
/**
* 修改角色
*/
public function toEdit(){
$m = new M();
return $m->edit();
}
/**
* 删除操作
*/
public function del(){
$m = new M();
$rs = $m->del();
return $rs;
}
}

View File

@ -0,0 +1,358 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\Goods;
use wstmart\common\model\GoodsCats;
use think\Loader;
/**
* ============================================================================
* 门店控制器
*/
class Shops extends Base{
protected $beforeActionList = [
'checkShopAuth' => ['only'=>'editinfo,getshopmoney'],
'checkAuth'=>['only'=>'join,joinstep1,joinstep2,savestep2,joinstep3,savestep3,joinstep4,savestep4,joinstep5,savestep5,joinsuccess']
];
/**
* 店铺公告页
*/
public function notice(){
$notice = model('shops')->getNotice();
$this->assign('notice',$notice);
return $this->fetch('shops/shops/notice');
}
/**
* 修改店铺公告
*/
public function editNotice(){
$s = model('shops');
return $s->editNotice();
}
/**
* 商家登录
*/
public function login(){
$USER = session('WST_USER');
if(!empty($USER) && isset($USER['shopId'])){
$this->redirect("shops/index");
}
$loginName = cookie("loginName");
if(!empty($loginName)){
$this->assign('loginName',cookie("loginName"));
}else{
$this->assign('loginName','');
}
return $this->fetch('shop_login');
}
/**
* 商家中心
*/
public function index(){
session('WST_MENID1',null);
session('WST_MENUID31',null);
$s = model('shops');
dump(session('WST_USER'));
$data = $s->getShopSummary((int)session('WST_USER.shopId'));
$this->assign('data',$data);
return $this->fetch('shops/index');
}
/**
* 店铺街
*/
public function shopStreet(){
$g = new GoodsCats();
$goodsCats = $g->listQuery(0);
$this->assign('goodscats',$goodsCats);
//店铺街列表
$s = model('shops');
$pagesize = 10;
$selectedId = input("get.id/d");
$this->assign('selectedId',$selectedId);
$list = $s->pageQuery($pagesize);
$this->assign('list',$list);
$this->assign('keyword',input('keyword'));
$this->assign('keytype',1);
return $this->fetch('shop_street');
}
/**
* 店铺详情
*/
public function home(){
$shopId = (int)input("param.shopId/d");
hook("homeBeforeGoShopHome",["shopId"=>$shopId]);
hook("goShopAfterAddView",["shopId"=>$shopId,'path'=>1]);
$s = model('shops');
$data['shop'] = $s->getShopInfo($shopId);
$ct1 = input("param.ct1/d",0);
$ct2 = input("param.ct2/d",0);
$goodsName = input("param.goodsName");
if(1778 != $shopId && !empty($this->is_icp)) return $this->fetch('error_lost');
if(($data['shop']['shopId']==1 || $shopId==0) && $ct1==0 && !isset($goodsName)){
$params = input();
unset($params["shopId"]);
$this->redirect(Url('home/shops/selfShop'),$params);
}
if(empty($data['shop']))return $this->fetch('error_lost');
$data['shopcats'] = $f = model('ShopCats','model')->getShopCats($shopId);
$g = model('goods');
$data['list'] = $g->shopGoods($shopId);
//dump($data['list']);die;
$this->assign('msort',input("param.msort/d",0));//筛选条件
$this->assign('mdesc',input("param.mdesc/d",1));//升降序
$this->assign('sprice',input("param.sprice"));//价格范围
$this->assign('eprice',input("param.eprice"));
$this->assign('ct1',$ct1);//一级分类
$this->assign('ct2',$ct2);//二级分类
$this->assign('goodsName',urldecode($goodsName));//搜索
$this->assign('data',$data);
return $this->fetch('shop_home');
}
/**
* 店铺分类
*/
public function cat(){
$s = model('shops');
$shopId = (int)input("param.shopId/d");
$data['shop'] = $s->getShopInfo($shopId);
$ct1 = input("param.ct1/d",0);
$ct2 = input("param.ct2/d",0);
$goodsName = input("param.goodsName");
if(($data['shop']['shopId']==1 || $shopId==0) && $ct1==0 && !isset($goodsName)){
$params = input();
unset($params["shopId"]);
$this->redirect('shops/selfShop',$params);
}
if(empty($data['shop']))return $this->fetch('error_lost');
$data['shopcats'] = $f = model('ShopCats','model')->getShopCats($shopId);
$g = model('goods');
$data['list'] = $g->shopGoods($shopId);
$this->assign('msort',input("param.msort/d",0));//筛选条件
$this->assign('mdesc',input("param.mdesc/d",1));//升降序
$this->assign('sprice',input("param.sprice"));//价格范围
$this->assign('eprice',input("param.eprice"));
$this->assign('ct1',$ct1);//一级分类
$this->assign('ct2',$ct2);//二级分类
$this->assign('goodsName',urldecode($goodsName));//搜索
$this->assign('data',$data);
return $this->fetch('shop_home');
}
/**
* 查看店铺设置
*/
public function info(){
$s = model('shops');
$object = $s->getByView((int)session('WST_USER.shopId'));
$bankList= model('banks')->listQuery();
$this->assign('bankList',$bankList);
$this->assign('object',$object);
return $this->fetch('shops/shops/view');
}
/**
* 自营店铺
*/
public function selfShop(){
hook("homeBeforeGoSelfShop",["shopId"=>1]);
$s = model('shops');
$data['shop'] = $s->getShopInfo(1);
if(empty($data['shop']))return $this->fetch('error_lost');
$this->assign('selfShop',1);
$data['shopcats'] = model('ShopCats')->getShopCats(1);
$this->assign('goodsName',urldecode(input("param.goodsName")));//搜索
// 店长推荐
$data['rec'] = $s->getRecGoods('rec',6);
// 热销商品
$data['hot'] = $s->getRecGoods('hot',6);
$this->assign('data',$data);
return $this->fetch('self_shop');
}
/**
* 编辑店铺资料
*/
public function editInfo(){
$rs = model('shops')->editInfo();
return $rs;
}
/**
* 获取店铺金额
*/
public function getShopMoney(){
$rs = model('shops')->getFieldsById((int)session('WST_USER.shopId'),'shopMoney,lockMoney,rechargeMoney');
$urs = model('users')->getFieldsById((int)session('WST_USER.userId'),'payPwd');
$rs['isSetPayPwd'] = ($urs['payPwd']=='')?0:1;
$rs['isDraw'] = ((float)WSTConf('CONF.drawCashShopLimit')<=$rs['shopMoney'])?1:0;
unset($urs);
return WSTReturn('',1,$rs);
}
/**
* 跳去商家入驻
*/
public function join(){
$rs = model('shops')->checkApply();
$this->assign('isApply',(!empty($rs) && $rs['applyStatus']>=1)?1:0);
$this->assign('applyStep',empty($rs)?1:$rs['applyStep']);
$articles = model('Articles')->getArticlesByCat(53);
// 防止不存在入驻文章时报错
if(!isset($articles['105']))$articles['105']['articleContent'] = '无相关说明,请咨询商城客服~';
if(!isset($articles['106']))$articles['106']['articleContent'] = '无相关说明,请咨询商城客服~';
if(!isset($articles['107']))$articles['107']['articleContent'] = '无相关说明,请咨询商城客服~';
if(!isset($articles['108']))$articles['108']['articleContent'] = '无相关说明,请咨询商城客服~';
$this->assign('artiles',$articles);
return $this->fetch('shop_join');
}
public function joinStep1(){
session('apply_step',1);
$rs = model('shops')->checkApply();
$articles = model('Articles')->getArticlesByCat(53);
// 防止不存在入驻文章时报错
if(!isset($articles['109']))$articles['109']['articleContent'] = '无相关说明,请咨询商城客服~';
$this->assign('artiles',$articles);
return $this->fetch('shop_join_step1');
}
public function joinStep2(){
$step = (int)session('apply_step');
if($step<1){
$this->redirect(Url('home/shops/joinStep1'));
exit();
}
session('apply_step',2);
$apply = model('shops')->getShopApply();
$this->assign('apply',$apply);
return $this->fetch('shop_join_step2');
}
public function saveStep2(){
$step = (int)session('apply_step');
if($step<2){
return WSTReturn('请勿跳过申请步骤');
}
$data = input('post.');
$validate = Loader::validate('Shops');
if(!$validate->check($data,[],'applyStep1')){
return WSTReturn($validate->getError());
}else{
return model('shops')->saveStep2($data);
}
}
public function joinStep3(){
$step = (int)session('apply_step');
if($step<2){
$this->redirect(Url('home/shops/joinStep1'));
exit();
}
session('apply_step',3);
$areas = model('Areas')->listQuery();
$this->assign('areaList',$areas);
$apply = model('shops')->getShopApply();
$this->assign('apply',$apply);
return $this->fetch('shop_join_step3');
}
public function saveStep3(){
$step = (int)session('apply_step');
if($step<3){
return WSTReturn('请勿跳过申请步骤');
}
$data = input('post.');
$validate = Loader::validate('Shops');
if(!$validate->check($data,[],'applyStep2')){
return WSTReturn($validate->getError());
}else{
return model('shops')->saveStep3($data);
}
}
public function joinStep4(){
$step = (int)session('apply_step');
if($step<3){
$this->redirect(Url('home/shops/joinStep4'));
exit();
}
session('apply_step',4);
$areas = model('Areas')->listQuery();
$this->assign('areaList',$areas);
$banks = model('banks')->listQuery();
$this->assign('bankList',$banks);
$apply = model('shops')->getShopApply();
$this->assign('apply',$apply);
return $this->fetch('shop_join_step4');
}
public function saveStep4(){
$step = (int)session('apply_step');
if($step<4){
return WSTReturn('请勿跳过申请步骤');
}
$data = input('post.');
$validate = Loader::validate('Shops');
if(!$validate->check($data,[],'applyStep3')){
return WSTReturn($validate->getError());
}else{
return model('shops')->saveStep4($data);
}
}
public function joinStep5(){
$step = (int)session('apply_step');
if($step<4){
$this->redirect(Url('home/shops/joinStep1'));
exit();
}
session('apply_step',5);
$shopLicense=db('shop_license')->alias('a')
->join('shops b','b.shopId= a.shopId')
->where('b.userId',(int)session("WST_USER.userId"))->find();
$this->assign('shopLicense',$shopLicense);
$goodsCatList = model('goodsCats')->listQuery(0);
$this->assign('goodsCatList',$goodsCatList);
$apply = model('shops')->getShopApply();
$this->assign('apply',$apply);
return $this->fetch('shop_join_step5');
}
public function saveStep5(){
$step = (int)session('apply_step');
if($step<5){
return WSTReturn('请勿跳过申请步骤');
}
$data = input('post.');
$validate = Loader::validate('Shops');
if(!$validate->check($data,[],'applyStep4')){
return WSTReturn($validate->getError());
}else{
return model('shops')->saveStep5($data);
}
}
public function joinSuccess(){
$step = (int)session('apply_step');
if($step<5){
$this->redirect(Url('home/shops/joinStep1'));
}
session('apply_step',5);
$apply = model('shops')->getShopApply();
$this->assign('apply',$apply);
return $this->fetch('shop_join_success');
}
/**
* 入驻进度查询
*/
public function checkapplystatus(){
$apply = model('shops')->getShopApply();
if(empty($apply)){
$this->redirect(Url('home/shops/joinStep1'));
exit();
}else{
if($apply['applyStatus']==0){
session('apply_step',$apply['applyStep']);
$this->redirect(Url('home/shops/joinStep'.$apply['applyStep']));
exit();
}else{
$this->assign('apply',$apply);
return $this->fetch('shop_join_success');
}
}
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace wstmart\home\controller;
use wstmart\home\model\ShopUsers as M;
/**
* ============================================================================
* 门店角色控制器
*/
class Shopusers extends Base{
protected $beforeActionList = ['checkShopAuth'];
/**
* 列表
*/
public function index(){
$m = new M();
$list = $m->pageQuery();
$this->assign('list',$list);
return $this->fetch("shops/shopusers/list");
}
/**
* 查询
*/
public function pageQuery(){
$m = new M();
return $m->pageQuery();
}
/**
* 新增店铺管理员
*/
public function add(){
$m = new M();
$object = $m->getEModel('shop_roles');
$roles = model("ShopRoles")->listQuery();
$data = ['object'=>$object,"roles"=>$roles];
return $this->fetch('shops/shopusers/add',$data);
}
/**
* 新增店铺管理员
*/
public function toAdd(){
$m = new M();
return $m->add();
}
/**
* 修改店铺管理员
*/
public function edit(){
$m = new M();
$object = $m->getById(input('get.id'));
$roles = model("ShopRoles")->listQuery();
$data = ['object'=>$object,"roles"=>$roles];
return $this->fetch('shops/shopusers/edit',$data);
}
/**
* 编辑店铺管理员
*/
public function toEdit(){
$m = new M();
return $m->edit();
}
/**
* 删除操作
*/
public function del(){
$m = new M();
$rs = $m->del();
return $rs;
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace wstmart\home\controller;
/**
* ============================================================================
* 关闭提示处理控制器
*/
use think\Controller;
class Switchs extends Controller{
public function __construct(){
parent::__construct();
$this->assign("v",WSTConf('CONF.wstVersion')."_".WSTConf('CONF.wstPCStyleId'));
}
protected function fetch($template = '', $vars = [], $replace = [], $config = []){
$style = WSTConf('CONF.wsthomeStyle')?WSTConf('CONF.wsthomeStyle'):'default';
$replace['__STYLE__'] = str_replace('/index.php','',\think\Request::instance()->root()).'/hyhproject/home/view/'.$style;
return $this->view->fetch($style."/".$template, $vars, $replace, $config);
}
public function index(){
return $this->fetch('error_switch');
}
}

View File

@ -0,0 +1,183 @@
<?php
namespace wstmart\home\controller;
Vendor('web3.vendor.autoload');
use \PHPUnit\Framework\TestCase as BaseTestCase;
use Web3\Web3;
/**
* ============================================================================
* 默认控制器
*/
class Tmp extends Base{
/**
* web3
*
* @var \Web3\Web3
*/
protected $web3;
/**
* testRinkebyHost
*
* @var string
*/
protected $testRinkebyHost = 'http://localhost';
/**
* testHost
*
* @var string
*/
protected $testHost = 'http://localhost:8545';
/**
* coinbase
*
* @var string
*/
protected $coinbase;
/**
* setUp
*
* @return void
*/
public function index(){
//Loader::import('web3.src.Web3');
$web3 = new Web3($this->testHost);
$this->web3 = $web3;
$personal = $web3->personal;
// $personal->batch(true);
// $personal->listAccounts();
// $personal->newAccount('123456');
// $personal->provider->execute(function ($err, $data) {
// if ($err !== null) {
// // do something
// return;
// }
// // do something
// });
//dump($personal);
$web3->eth->coinbase(function ($err, $coinbase) {
if ($err !== null) {
dump($this->fail($err->getMessage()));
}
$this->coinbase = $coinbase;
});
$eth = $web3->eth;
$eth->accounts(function ($err, $accounts) use ($eth) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
dump($accounts);
});
// $personal->unlockAccount($this->coinbase, '123456', function ($err, $unlocked) {
// if ($err !== null) {
// echo 'Error: ' . $err->getMessage();
// return;
// }
// if ($unlocked) {
// echo 'New account is unlocked!' . PHP_EOL;
// } else {
// echo 'New account isn\'t unlocked' . PHP_EOL;
// }
// });
$web3->eth->getBalance( $this->coinbase , function ($err, $balance) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
echo 'Balance: ' . $balance->toString() . PHP_EOL;
});
$newAccount = '';
$web3->personal->newAccount('123456', function ($err, $account) use (&$newAccount) {
dump($err);
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
$newAccount = $account;
echo 'New account: ' . $account . PHP_EOL;
});
dump($this->coinbase);
// $web3->eth->getWork(function ($err, $coinbase) {
// if ($err !== null) {
// dump($this->fail($err->getMessage()));
// }
// dump($coinbase);
// });
// $web3->clientVersion(function ($err, $version) {
// if ($err !== null) {
// // do something
// return;
// }
// dump($version);die;
// if (isset($client)) {
// echo 'Client version: ' . $version;
// }
// });
die;
$web3 = new Web3('http://localhost:8545');
//$getPersonal = $web3->getEth;
$personal = $web3->personal;
$newAccount = '';
echo 'Personal Create Account and Unlock Account' . PHP_EOL;
// create account
$personal->newAccount('123456', function ($err, $account) use (&$newAccount) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
$newAccount = $account;
echo 'New account: ' . $account . PHP_EOL;
});
$personal->unlockAccount($newAccount, '123456', function ($err, $unlocked) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
if ($unlocked) {
echo 'New account is unlocked!' . PHP_EOL;
} else {
echo 'New account isn\'t unlocked' . PHP_EOL;
}
});
// get balance
$web3->eth->getBalance($newAccount, function ($err, $balance) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
echo 'Balance: ' . $balance->toString() . PHP_EOL;
});
die;
}
}

View File

@ -0,0 +1,230 @@
<?php
namespace wstmart\home\controller;
use think\Loader;
use wstmart\common\model\Payments as M;
use wstmart\common\model\Orders as OM;
use wstmart\common\model\LogMoneys as LM;
/**
* ============================================================================
* 银联支付控制器
*/
class Unionpays extends Base{
/**
* 初始化
*/
private $unionConfig;
public function _initialize() {
header ("Content-type: text/html; charset=utf-8");
Loader::import('unionpay.sdk.acp_service');
$m = new M();
$this->unionConfig = $m->getPayment("unionpays");
$config = array();
$config["signCertPwd"] = $this->unionConfig["unionSignCertPwd"];//"000000"
$config["signMethod"] = "01";
$config["frontUrl"] = url("home/unionpays/response","",true,true);
$config["backUrl"] = url("home/unionpays/notify","",true,true);
new \SDKConfig($config);
}
public function getUnionpaysUrl(){
$m = new OM();
$payObj = input("payObj/s");
$data = array();
if($payObj=="recharge"){
$needPay = input("needPay/d");
$data["status"] = $needPay>0?1:-1;
}else{
$userId = (int)session('WST_USER.userId');
$data = $m->checkOrderPay();
}
return $data;
}
/**
* 生成支付代码
* @param array $order 订单信息
* @param array $config_value 支付方式信息
*/
public function toUnionpays(){
$payObj = input("payObj/s");
$m = new OM();
$obj = array();
$data = array();
$orderAmount = 0;
$orderId = "";
$extra_param = "";
if($payObj=="recharge"){//充值
$itmeId = (int)input("itmeId/d");
$orderAmount = 0;
if($itmeId>0){
$item = $cm->getItemMoney($itmeId);
$orderAmount = isSet($item["chargeMoney"])?$item["chargeMoney"]:0;
}else{
$orderAmount = (int)input("needPay/d");
}
$shopId = (int)session('WST_USER.shopId');
$targetType = ($shopId>0)?1:0;
$targetId = (int)session('WST_USER.userId');
if($targetType==1){//商家
$targetId = $shopId;
}
$data["status"] = $orderAmount>0?1:-1;
$orderId = WSTOrderNo();
$extra_param = $payObj."|".$targetId."|".$targetType."|".$itmeId;
}else{
$obj["orderNo"] = input("orderNo/s");
$obj["isBatch"] = (int)input("isBatch/d");
$data = $m->checkOrderPay($obj);
if($data["status"]==1){
$userId = (int)session('WST_USER.userId');
$obj["userId"] = $userId;
$order = $m->getPayOrders($obj);
$orderAmount = $order["needPay"];
$payRand = $order["payRand"];
$orderId = $obj["orderNo"]."a".$payRand;
$extra_param = $payObj."|".$userId."|".$obj["isBatch"];
}
}
if($data["status"]==1){
$params = array(
//以下信息非特殊情况不需要改动
'version' => \SDKConfig::$version, //版本号
'encoding' => 'utf-8', //编码方式
'txnType' => '01', //交易类型
'txnSubType' => '01', //交易子类
'bizType' => '000201', //业务类型
'frontUrl' => \SDKConfig::$frontUrl, //前台通知地址
'backUrl' => \SDKConfig::$backUrl, //后台通知地址
'signMethod' => \SDKConfig::$signMethod,//签名方法
'channelType' => '07', //渠道类型07-PC08-手机
'accessType' => '0', //接入类型
'currencyCode' => '156', //交易币种境内商户固定156
//TODO 以下信息需要填写
'merId' => $this->unionConfig["unionMerId"], //"777290058110048",//商户代码
'orderId' => $orderId, //商户订单号8-32位数字字母不能含“-”或“_”
'txnTime' => date('YmdHis'), //订单发送时间格式为YYYYMMDDhhmmss取北京时间
'txnAmt' => $orderAmount*100, //交易金额单位分此处默认取demo演示页面传递的参数
// 订单超时时间。
//'payTimeout' => date('YmdHis', strtotime('+15 minutes')),
'reqReserved' => $extra_param,
);
$acpService = new \AcpService();
$acpService::sign ( $params );
$uri = \SDKConfig::$frontTransUrl;
$html_form = $acpService::createAutoFormHtml( $params, $uri );
echo $html_form;
}else{
}
}
/**
* 异步回调接口
*/
public function notify(){
//计算得出通知验证结果
$acpService = new \AcpService(); // 使用银联原生自带的累 和方法 这里只是引用了一下 而已
$verify_result = $acpService->validate($_POST);
if($verify_result){//验证成功
$out_trade_no = $_POST['orderId']; //商户订单号
$queryId = $_POST['queryId']; //银联支付流水号
// 解释: 交易成功且结束,即不可再做任何操作。
if($_POST['respMsg'] == 'Success!'){
$m = new OM();
$extras = explode("|",$_POST['reqReserved']);
$rs = array();
if($extras[0]=="recharge"){//充值
$targetId = (int)$extras [1];
$targetType = (int)$extras [2];
$itemId = (int)$extras [3];
$obj = array ();
$obj["trade_no"] = $_POST['trade_no'];
$obj["out_trade_no"] = $_POST["out_trade_no"];;
$obj["targetId"] = $targetId;
$obj["targetType"] = $targetType;
$obj["itemId"] = $itemId;
$obj["total_fee"] = $_POST['total_fee'];
$obj["payFrom"] = 'unionpays';
// 支付成功业务逻辑
$m = new LM();
$rs = $m->complateRecharge ( $obj );
}else{
//商户订单号
$obj = array();
$tradeNo = explode("a",$out_trade_no);
$obj["trade_no"] = $_POST['trade_no'];
$obj["out_trade_no"] = $tradeNo[0];
$obj["total_fee"] = $_POST['total_fee'];
$obj["userId"] = $extras[1];
$obj["isBatch"] = $extras[2];
$obj["payFrom"] = 'unionpays';
//支付成功业务逻辑
$rs = $m->complatePay($obj);
}
if($rs["status"]==1){
echo 'success';
}else{
echo 'fail';
}
}
}else{
echo "fail"; //验证失败
}
}
/**
* 同步回调接口
*/
public function response(){
//计算得出通知验证结果
$acpService = new \AcpService(); // 使用银联原生自带的累 和方法 这里只是引用了一下 而已
$verify_result = $acpService->validate($_POST);
if($verify_result){ //验证成功
$order_sn = $out_trade_no = $_POST['orderId']; //商户订单号
$queryId = $_POST['queryId']; //银联支付流水号
$respMsg = $_POST['respMsg']; //交易状态
if($_POST['respMsg'] == 'success'){
$m = new OM();
$extras = explode("|",$_POST['extra_param']);
if($extras[0]=="recharge"){//充值
if($extras[2]==1){
$this->redirect(url("home/logmoneys/shopmoneys"));
}else{
$this->redirect(url("home/logmoneys/usermoneys"));
}
}else{
$obj = array();
$tradeNo = explode("a",$out_trade_no);
$obj["orderNo"] = $tradeNo[0];
$obj["userId"] = $extras[1];
$obj["isBatch"] = $extras[2];
$rs = $m->getOrderType($obj);
if((int)$rs["orderType"]==1){
$this->redirect(url("home/orders/waitAppraise"));
}else{
$this->redirect(url("home/orders/waitReceive"));
}
}
}else {
$this->error('支付失败');
}
}else {
$this->error('支付失败');
}
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\LogSms;
/**
* ============================================================================
* 用户地址控制器
*/
class Useraddress extends Base{
protected $beforeActionList = ['checkAuth'];
/**
* 设置为默认地址
*/
public function setDefault(){
return model('userAddress')->setDefault();
}
public function index(){
return $this->fetch('users/useraddress/list');
}
/**
* 获取地址信息
* 1.购物车结算有引用
*/
public function listQuery(){
//获取用户信息
$userId = (int)session('WST_USER.userId');
if(!$userId){
return WSTReturn('未登录', -1);
}
$list = model('Home/userAddress')->listQuery($userId);
return WSTReturn('', 1,$list);
}
/**
* 跳去修改地址
*/
public function edit(){
$m = model('userAddress');
$id=(int)input('id');
$data = $m->getById($id);
$data = empty($data)?$m->getEModel('user_address'):$data;
//获取省级地区信息
$area1 = model('Areas')->listQuery(0);
$this->assign(['data'=>$data,
'area1'=>$area1]);
return $this->fetch('users/useraddress/edit');
}
/**
* 新增
*/
public function add(){
$m = model('userAddress');
$rs = $m->add();
return $rs;
}
/**
* 修改
*/
public function toEdit(){
$m = model('userAddress');
$rs = $m->edit();
return $rs;
}
/**
* 删除
*/
public function del(){
$m = model('userAddress');
$rs = $m->del();
return $rs;
}
/**
* 获取用户地址
*/
public function getById(){
$m = model('userAddress');
$id=(int)input('id');
$data = $m->getById($id);
return WSTReturn('', 1,$data);
}
}

View File

@ -0,0 +1,974 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Users as MUsers;
use wstmart\common\model\LogSms;
/**
* ============================================================================
* 用户控制器
*/
class Users extends Base{
protected $beforeActionList = [
'checkAuth' => ['except'=>'getverify,login,logout,regist,toregist,checklogin,getphoneverifycode,checkloginkey,checkemail,checkfindkey,protocol,forgetpass,forgetpasst,resetpass,forgetpasss,forgetpassf,findpass,getfindphone,checkfindphone,getfindemail,tologinbox']
];
/**
* 去登录
*/
public function login(){
$USER = session('WST_USER');
//如果已经登录了则直接跳去用户中心
if(!empty($USER) && !empty($USER['userId'])){
$this->redirect("users/index");
}
$loginName = cookie("loginName");
if(!empty($loginName)){
$this->assign('loginName',cookie("loginName"));
}else{
$this->assign('loginName','');
}
return $this->fetch('user_login');
}
/**
* 用户退出
*/
public function logout(){
session('WST_USER',null);
setcookie("loginPwd", null);
session('WST_HO_CURRENTURL', null);
hook('afterUserLogout');
return WSTReturn("退出成功",1);
}
/**
* 用户注册
*
*/
public function regist(){
$USER = session('WST_USER');
//如果已经登录了则直接跳去用户中心
if(!empty($USER) && $USER['userId']!=''){
$this->redirect("users/index");
}
$loginName = cookie("loginName");
if(!empty($loginName)){
$this->assign('loginName',cookie("loginName"));
}else{
$this->assign('loginName','');
}
return $this->fetch('regist');
}
/**
* 新用户注册
*/
public function toRegist(){
$m = new MUsers();
$rs = $m->regist();
$rs['url'] = session('WST_HO_CURRENTURL');
return $rs;
}
/**
* 验证登录
*
*/
public function checkLogin(){
$m = new MUsers();
$rs = $m->checkLogin();
$rs['url'] = session('WST_HO_CURRENTURL');
return $rs;
}
/**
* 获取验证码
*/
public function getPhoneVerifyCode(){
$userPhone = input("post.userPhone");
$rs = array();
if(!WSTIsPhone($userPhone)){
return WSTReturn("手机号格式不正确!");
exit();
}
$m = new MUsers();
$rs = $m->checkUserPhone($userPhone,(int)session('WST_USER.userId'));
if($rs["status"]!=1){
return WSTReturn("手机号已存在!");
exit();
}
$phoneVerify = rand(100000,999999);
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
$tpl = WSTMsgTemplates('PHONE_USER_REGISTER_VERFIY');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['MALL_NAME'=>WSTConf("CONF.mallName"),'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
$m = new LogSms();
$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerify',$phoneVerify);
}
if($rv['status']==1){
session('VerifyCode_userPhone',$phoneVerify);
session('VerifyCode_userPhone_Time',time());
}
return $rv;
}
/**
* 判断手机或邮箱是否存在
*/
public function checkLoginKey(){
$m = new MUsers();
if(input("post.loginName"))$val=input("post.loginName");
if(input("post.userPhone"))$val=input("post.userPhone");
if(input("post.userEmail"))$val=input("post.userEmail");
$userId = (int)session('WST_USER.userId');
$rs = WSTCheckLoginKey($val,$userId);
if($rs["status"]==1){
return array("ok"=>"");
}else{
return array("error"=>$rs["msg"]);
}
}
/**
* 判断邮箱是否存在
*/
public function checkEmail(){
$data = $this->checkLoginKey();
if(isset($data['error']))$data['error'] = '对不起,该邮箱已存在';
return $data;
}
/**
* 判断用户名是否存在/忘记密码
*/
public function checkFindKey(){
$m = new MUsers();
$userId = (int)session('WST_USER.userId');
$rs = WSTCheckLoginKey(input("post.loginName"),$userId);
if($rs["status"]==1){
return array("error"=>"该用户不存在!");
}else{
return array("ok"=>"");
}
}
/**
* 跳到用户注册协议
*/
public function protocol(){
return $this->fetch("user_protocol");
}
/**
* 用户中心
*/
public function index(){
session('WST_MENID0',0);
session('WST_MENUID30',0);
// 待付款 待收货 待评价
$info = model('home/Users')->getStatusNum();
$this->assign($info);
$m = new MUsers();
$data = $m->getById((int)session('WST_USER.userId'));
$this->assign('data',$data);
return $this->fetch('users/index');
}
/**
* 跳去修改个人资料
*/
public function edit(){
$m = new MUsers();
//获取用户信息
$userId = (int)session('WST_USER.userId');
$data = $m->getById($userId);
$this->assign('data',$data);
return $this->fetch('users/user_edit');
}
/**
* 跳去修改密码页
*/
public function editPass(){
$m = new MUsers();
//获取用户信息
$userId = (int)session('WST_USER.userId');
$data = $m->getById($userId);
$this->assign('data',$data);
return $this->fetch('users/security/user_pass');
}
/**
* 修改密码
*/
public function passedit(){
$userId = (int)session('WST_USER.userId');
$m = new MUsers();
$rs = $m->editPass($userId);
return $rs;
}
/**
* 修改
*/
public function toEdit(){
$m = new MUsers();
$rs = $m->edit();
return $rs;
}
/**
* 安全设置页
*/
public function security(){
//获取用户信息
$m = new MUsers();
$data = $m->getById((int)session('WST_USER.userId'));
if($data['userPhone']!='')$data['userPhone'] = WSTStrReplace($data['userPhone'],'*',3);
if($data['userEmail']!='')$data['userEmail'] = WSTStrReplace($data['userEmail'],'*',2,'@');
$this->assign('data',$data);
return $this->fetch('users/security/index');
}
/**
* 修改邮箱页
*/
public function editEmail(){
hook('homeControllerUsersEditEmail');
//获取用户信息
$userId = (int)session('WST_USER.userId');
$m = new MUsers();
$data = $m->getById($userId);
if($data['userEmail']!='')$data['userEmail'] = WSTStrReplace($data['userEmail'],'*',2,'@');
$this->assign('data',$data);
$process = 'One';
$this->assign('process',$process);
if($data['userEmail']){
return $this->fetch('users/security/user_edit_email');
}else{
return $this->fetch('users/security/user_email');
}
}
/**
* 发送验证邮件/绑定邮箱
*/
public function getEmailVerify(){
$userEmail = input('post.userEmail');
if(!$userEmail){
return WSTReturn('请输入邮箱!',-1);
}
$code = input("post.verifyCode");
$process = input("post.process");
if(!WSTVerifyCheck($code)){
return WSTReturn('验证码错误!',-1);
}
$rs = WSTCheckLoginKey($userEmail,(int)session('WST_USER.userId'));
if($rs["status"]!=1){
return WSTReturn("邮箱已存在!");
exit();
}
$code = rand(0,999999);
$sendRs = ['status'=>-1,'msg'=>'邮件发送失败'];
$tpl = WSTMsgTemplates('EMAIL_BIND');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$find = ['${LOGIN_NAME}','${SEND_TIME}','${VERFIY_CODE}','${VERFIY_TIME}'];
$replace = [session('WST_USER.loginName'),date('Y-m-d H:i:s'),$code,30];
$sendRs = WSTSendMail($userEmail,'绑定邮箱',str_replace($find,$replace,$tpl['content']));
}
if($sendRs['status']==1){
// 绑定的邮箱
session('email.val',$userEmail);
// 验证码
session("email.key", $code);
// 发起绑定邮箱的时间;
session('email.time',time());
return WSTReturn("发送成功",1);
}else{
return WSTReturn($sendRs['msg'],-1);
}
}
/**
* 绑定邮箱
*/
public function emailEdit(){
$USER = session('WST_USER');
if(empty($USER) && $USER['userId']==''){
$this->redirect("home/users/login");
}
$bindTime = session('email.time');
$code = session('email.key');
$bindEmail = session('email.val');
if(time()>floatval($bindTime)+30*60)$this->error('验证码已失效!');
$rs = WSTCheckLoginKey($bindEmail,(int)session('WST_USER.userId'));
if($rs["status"]!=1){
$this->error('邮箱已存在!');
exit();
}
$secretCode = input('secretCode');
if($code!=$secretCode)return WSTReturn('校验码错误',-1);
$m = new MUsers();
$rs = $m->editEmail((int)session('WST_USER.userId'),$bindEmail);
if($rs['status'] == 1){
// 清空session
session('email',null);
return WSTReturn('验证通过',1);
}
$this->error('绑定邮箱失败');
}
/**
* 完成邮箱绑定
*/
public function doneEmailBind(){
$this->assign('process','Three');
return $this->fetch('users/security/user_email');
}
/**
* 发送验证邮件/修改邮箱
*/
public function getEmailVerifyt(){
$m = new MUsers();
$data = $m->getById(session('WST_USER.userId'));
$userEmail = $data['userEmail'];
if(!$userEmail){
return WSTReturn('请输入邮箱!',-1);
}
$code = input("post.verifyCode");
if(!WSTVerifyCheck($code)){
return WSTReturn('验证码错误!',-1);
}
$code = rand(0,999999);
$sendRs = ['status'=>-1,'msg'=>'邮件发送失败'];
$tpl = WSTMsgTemplates('EMAIL_EDIT');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$find = ['${LOGIN_NAME}','${SEND_TIME}','${VERFIY_CODE}','${VERFIY_TIME}'];
$replace = [session('WST_USER.loginName'),date('Y-m-d H:i:s'),$code,30];
$sendRs = WSTSendMail($userEmail,'绑定邮箱',str_replace($find,$replace,$tpl['content']));
}
if($sendRs['status']==1){
// 修改的用户
session('email.uId',(int)session('WST_USER.userId'));
// 绑定的邮箱
session('email.val',$userEmail);
// 验证码
session("email.key", $code);
// 发起绑定邮箱的时间;
session('email.time',time());
return WSTReturn("发送成功",1);
}else{
return WSTReturn($sendRs['msg'],-1);
}
}
/**
* 修改邮箱
*/
public function emailEditt(){
$USER = session('WST_USER');
if(empty($USER) && $USER['userId']!=''){
$this->redirect("home/users/login");
}
$bindTime = session('email.time');
$code = session('email.key');
$bindEmail = session('email.val');
$uId = (int)session('email.uId');
if(time()>floatval($bindTime)+30*60)$this->error('验证码已失效!');
$rs = WSTCheckLoginKey($bindEmail,(int)session('WST_USER.userId'));
if($rs["status"]!=1){
$this->error('邮箱已存在!');
exit();
}
$secretCode = input('secretCode');
if($code!=$secretCode)return WSTReturn('校验码错误',-1);
$m = new MUsers();
$data = $m->getById($uId);
if($data['userId']==session('WST_USER.userId')){
return WSTReturn('验证通过',1);
}
$this->error('无效的用户!');
}
/**
* 修改邮箱第二步
*/
public function editEmail2(){
$this->assign('process','Two');
return $this->fetch('users/security/user_edit_email');
}
/**
* 修改邮箱第三步
*/
public function editEmail3(){
$this->assign('process','Three');
return $this->fetch('users/security/user_edit_email');
}
/**
* 修改手机页
*/
public function editPhone(){
//获取用户信息
$userId = (int)session('WST_USER.userId');
$m = new MUsers();
$data = $m->getById($userId);
if($data['userPhone']!='')$data['userPhone'] = WSTStrReplace($data['userPhone'],'*',3);
$this->assign('data',$data);
$process = 'One';
$this->assign('process',$process);
if($data['userPhone']){
return $this->fetch('users/security/user_edit_phone');
}else{
return $this->fetch('users/security/user_phone');
}
}
/**
* 跳到发送手机验证
*/
public function toApply(){
return $this->fetch("user_verify_phone");
}
/**
* 绑定手机/获取验证码
*/
public function getPhoneVerifyo(){
$userPhone = input("post.userPhone");
if(!WSTIsPhone($userPhone)){
return WSTReturn("手机号格式不正确!");
exit();
}
$rs = array();
$m = new MUsers();
$rs = WSTCheckLoginKey($userPhone,(int)session('WST_USER.userId'));
if($rs["status"]!=1){
return WSTReturn("手机号已存在!");
exit();
}
$data = $m->getById(session('WST_USER.userId'));
$phoneVerify = rand(100000,999999);
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
$tpl = WSTMsgTemplates('PHONE_EDIT');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
$m = new LogSms();
$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyo',$phoneVerify);
}
if($rv['status']==1){
$USER = [];
$USER['userPhone'] = $userPhone;
$USER['phoneVerify'] = $phoneVerify;
session('Verify_info',$USER);
session('Verify_userPhone_Time',time());
return WSTReturn('短信发送成功!',1);
}
return $rv;
}
/**
* 绑定手机
*/
public function getPhoneVerifyb(){
$userPhone = input("post.userPhone");
if(!WSTIsPhone($userPhone)){
return WSTReturn("手机号格式不正确!");
exit();
}
$rs = array();
$m = new MUsers();
$rs = WSTCheckLoginKey($userPhone,(int)session('WST_USER.userId'));
if($rs["status"]!=1){
return WSTReturn("手机号已存在!");
exit();
}
$data = $m->getById(session('WST_USER.userId'));
$phoneVerify = rand(100000,999999);
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
$tpl = WSTMsgTemplates('PHONE_BIND');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
$m = new LogSms();
$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyb',$phoneVerify);
}
if($rv['status']==1){
$USER = [];
$USER['userPhone'] = $userPhone;
$USER['phoneVerify'] = $phoneVerify;
session('Verify_info',$USER);
session('Verify_userPhone_Time',time());
return WSTReturn('短信发送成功!',1);
}
return $rv;
}
/**
* 绑定手机
*/
public function phoneEdito(){
$phoneVerify = input("post.Checkcode");
$process = input("post.process");
$timeVerify = session('Verify_userPhone_Time');
if(!session('Verify_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
return WSTReturn("地址已失效,请重新验证身份!");
exit();
}
if($phoneVerify==session('Verify_info.phoneVerify')){
$m = new MUsers();
$rs = $m->editPhone((int)session('WST_USER.userId'),session('Verify_info.userPhone'));
if($process=='Two'){
$rs['process'] = $process;
}else{
$rs['process'] = '0';
}
return $rs;
}
return WSTReturn("校验码不一致,请重新输入!");
}
public function editPhoneSu(){
$pr = input("get.pr");
$process = 'Three';
$this->assign('process',$process);
if($pr == 'Two'){
return $this->fetch('users/security/user_edit_phone');
}else{
return $this->fetch('users/security/user_phone');
}
}
/**
* 修改手机/获取验证码
*/
public function getPhoneVerifyt(){
$m = new MUsers();
$data = $m->getById(session('WST_USER.userId'));
$userPhone = $data['userPhone'];
$phoneVerify = rand(100000,999999);
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
$tpl = WSTMsgTemplates('PHONE_EDIT');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
$m = new LogSms();
$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyt',$phoneVerify);
}
if($rv['status']==1){
$USER = [];
$USER['userPhone'] = $userPhone;
$USER['phoneVerify'] = $phoneVerify;
session('Verify_info2',$USER);
session('Verify_userPhone_Time2',time());
return WSTReturn('短信发送成功!',1);
}
return $rv;
}
/**
* 修改手机
*/
public function phoneEditt(){
$phoneVerify = input("post.Checkcode");
$timeVerify = session('Verify_userPhone_Time2');
if(!session('Verify_info2.phoneVerify') || time()>floatval($timeVerify)+10*60){
return WSTReturn("校验码已失效,请重新发送!");
exit();
}
if($phoneVerify==session('Verify_info2.phoneVerify')){
return WSTReturn("验证成功",1);
}
return WSTReturn("校验码不一致,请重新输入!",-1);
}
public function editPhoneSut(){
$process = 'Two';
$this->assign('process',$process);
if(session('Verify_info2.phoneVerify')){
return $this->fetch('users/security/user_edit_phone');
}
$this->error('地址已失效,请重新验证身份');
}
/**
* 处理图像裁剪
*/
// public function editUserPhoto(){
// $imageSrc = trim(input('post.photoSrc'),'/');
// $image = \image\Image::open($imageSrc);
// $x = (int)input('post.x');
// $y = (int)input('post.y');
// $w = (int)input('post.w',150);
// $h = (int)input('post.h',150);
// $rs = $image->crop($w, $h, $x, $y, 150, 150)->save($imageSrc);
// if($rs){
// return WSTReturn('',1,$imageSrc);
// exit;
// }
// return WSTReturn('发生未知错误.',-1);
// }
/**
* 处理图像裁剪 修改适应oss mark 201080612 by zl
*/
public function editUserPhoto(){
$imageSrc = trim(input('post.photoSrc'),'/');
//判断图片是否缩放了
$res = strpos($imageSrc,'?x-oss-process=');
$x = (int)input('post.x');
$y = (int)input('post.y');
$w = (int)input('post.w',150);
$h = (int)input('post.h',150);
//判断是否缩放 如果缩放了就不加'?x-oss-process='
if($res){
$imageSrc=$imageSrc.',image/crop,x_'.$x.',y_'.$y.',w_'.$w.',h_'.$h.',image/resize,w_150,h_150';
}else{
$imageSrc=$imageSrc.'?x-oss-process=image/crop,x_'.$x.',y_'.$y.',w_'.$w.',h_'.$h.',image/resize,w_150,h_150';
}
return WSTReturn('',1,$imageSrc);
}
/****************************************************** 忘记密码 **********************************************************/
/**
* 忘记支付密码
*/
public function backPayPass(){
$m = new MUsers();
$userId = (int)session('WST_USER.userId');
$user = $m->getById($userId);
$userPhone = $user['userPhone'];
$user['userPhone'] = WSTStrReplace($user['userPhone'],'*',3);
$user['phoneType'] = empty($userPhone)?0:1;
$backType = (int)session('Type_backPaypwd');
$timeVerify = session('Verify_backPaypwd_Time');
$process = 'One';
$this->assign('data', $user);
$this->assign('process', $process);
return $this->fetch('users/security/user_edit_pay');
}
/**
* 忘记支付密码:发送短信
*/
public function getphoneverifypay(){
$m = new MUsers();
$data = $m->getById(session('WST_USER.userId'));
$userPhone = $data['userPhone'];
$phoneVerify = rand(100000,999999);
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
$tpl = WSTMsgTemplates('PHONE_FOTGET_PAY');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
$m = new LogSms();
$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyt',$phoneVerify);
}
if($rv['status']==1){
$USER = [];
$USER['userPhone'] = $userPhone;
$USER['phoneVerify'] = $phoneVerify;
session('Verify_backPaypwd_info',$USER);
session('Verify_backPaypwd_Time',time());
return WSTReturn('短信发送成功!',1);
}
return $rv;
}
/**
* 忘记支付密码:验证
*/
public function payEditt(){
$payVerify = input("post.Checkcode");
$timeVerify = session('Verify_backPaypwd_Time');
if(!session('Verify_backPaypwd_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
return WSTReturn("校验码已失效,请重新发送!");
exit();
}
if($payVerify==session('Verify_backPaypwd_info.phoneVerify')){
return WSTReturn("验证成功",1);
}
return WSTReturn("校验码不一致,请重新输入!",-1);
}
public function editPaySut(){
$process = 'Two';
$this->assign('process',$process);
if(session('Verify_backPaypwd_info.phoneVerify')){
return $this->fetch('users/security/user_edit_pay');
}
$this->error('地址已失效,请重新验证身份');
}
/**
* 忘记支付密码:设置
*/
public function payEdito(){
$process = input("post.process");
$timeVerify = session('Verify_backPaypwd_Time');
if(!session('Verify_backPaypwd_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
return WSTReturn("地址已失效,请重新验证身份!");
exit();
}
$m = new MUsers();
$rs = $m->resetbackPay();
if($process=='Two'){
$rs['process'] = $process;
}else{
$rs['process'] = '0';
}
return $rs;
}
/**
* 忘记支付密码:完成
*/
public function editPaySu(){
$pr = input("get.pr");
$process = 'Three';
$this->assign('process',$process);
if($pr == 'Two'){
return $this->fetch('users/security/user_edit_pay');
}else{
return $this->fetch('users/security/user_pay_pass');
}
}
/**
* 忘记密码
*/
public function forgetPass(){
return $this->fetch('forget_pass');
}
public function forgetPasst(){
if(time()<floatval(session('findPass.findTime'))+30*60){
$userId = session('findPass.userId');
$m = new MUsers();
$info = $m->getById($userId);
if($info['userPhone']!='')$info['userPhone'] = WSTStrReplace($info['userPhone'],'*',3);
if($info['userEmail']!='')$info['userEmail'] = WSTStrReplace($info['userEmail'],'*',2,'@');
$this->assign('forgetInfo',$info);
return $this->fetch('forget_pass2');
}else{
$this->error('页面已过期!');
}
}
// 重置密码
public function resetPass(){
if(!session('findPass')){
$this->error('连接已失效!',url('home/users/index'));
}
if(time()>floatval(session('REST_Time'))+30*60)$this->error('连接已失效!');
return $this->fetch('forget_pass3');
}
// 验证校验码
public function forgetPasss(){
if(!session('findPass')){
$this->error('连接已失效!');
}
if(time()>floatval(session('REST_Time'))+30*60)$this->error('连接已失效!');
$USER = session('findPass');
if(empty($USER) && $USER['userId']!=''){
$this->error('请在同一浏览器操作!');
}
$USER = session('findPass');
if(empty($USER) && $USER['userId']!=''){
$this->expire('请在同一浏览器操作!');
}
$uId = session('findPass.userId');
$key = session("findPass.key");
// 验证邮箱中的验证码
$secretCode = input('secretCode');
if($key==$secretCode){
session('REST_userId',$uId);
session('REST_success','1');
return WSTReturn('验证成功',1);
}else{
return WSTReturn('校验码错误',-1);
}
}
public function forgetPassf(){
return $this->fetch('forget_pass4');
}
/**
* 找回密码
*/
public function findPass(){
//禁止缓存
header('Cache-Control:no-cache,must-revalidate');
header('Pragma:no-cache');
$code = input("post.verifyCode");
$step = input("post.step/d");
switch ($step) {
case 1:#第一步,验证身份
if(!WSTVerifyCheck($code)){
return WSTReturn('验证码错误!',-1);
}
$loginName = input("post.loginName");
$rs = WSTCheckLoginKey($loginName);
if($rs["status"]==1){
return WSTReturn("用户名不存在!");
exit();
}
$m = new MUsers();
$info = $m->checkAndGetLoginInfo($loginName);
if ($info != false) {
session('findPass',array('userId'=>$info['userId'],'loginName'=>$loginName,'userPhone'=>$info['userPhone'],'userEmail'=>$info['userEmail'],'loginSecret'=>$info['loginSecret'],'findTime'=>time()));
return WSTReturn("操作成功",1);
}else return WSTReturn("用户名不存在!");
break;
case 2:#第二步,验证方式
if (session('findPass.loginName') != null ){
if(input("post.modes")==1){
if ( session('findPass.userPhone') == null) {
return WSTReturn('你没有预留手机号码,请通过邮箱方式找回密码!',-1);
}
$phoneVerify = input("post.Checkcode");
if(!$phoneVerify){
return WSTReturn('校验码不能为空!',-1);
}
return $this->checkfindPhone($phoneVerify);
}else{
if (session('findPass.userEmail')==null) {
return WSTReturn('你没有预留邮箱,请通过手机号码找回密码!',-1);
}
if(!WSTVerifyCheck($code)){
return WSTReturn('验证码错误!',-1);
}
return $this->getfindEmail();
}
}else $this->error('页面已过期!');
break;
case 3:#第三步,设置新密码
$resetPass = session('REST_success');
if($resetPass != 1)$this->error("页面已失效!");
$loginPwd = input("post.loginPwd");
$repassword = input("post.repassword");
$decrypt_data = WSTRSA($loginPwd);
$decrypt_data2 = WSTRSA($repassword);
if($decrypt_data['status']==1 && $decrypt_data2['status']==1){
$loginPwd = $decrypt_data['data'];
$repassword = $decrypt_data2['data'];
}else{
return WSTReturn('设置失败');
}
if ($loginPwd == $repassword) {
$m = new MUsers();
$rs = $m->resetPass();
if($rs['status']==1){
return $rs;
}else{
return $rs;
}
}else return WSTReturn('两次密码不同!',-1);
break;
default:
$this->error('页面已过期!');
break;
}
}
/**
* 手机验证码获取
*/
public function getfindPhone(){
session('WST_USER',session('findPass.userId'));
if(session('findPass.userPhone')==''){
return WSTReturn('你没有预留手机号码,请通过邮箱方式找回密码!',-1);
}
$phoneVerify = rand(100000,999999);
session('WST_USER',null);
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
$tpl = WSTMsgTemplates('PHONE_FOTGET');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
$m = new LogSms();
$rv = $m->sendSMS(0,session('findPass.userPhone'),$params,'getPhoneVerify',$phoneVerify);
}
if($rv['status']==1){
// 记录发送短信的时间,用于验证是否过期
session('REST_Time',time());
$USER = [];
$USER['phoneVerify'] = $phoneVerify;
$USER['time'] = time();
session('findPhone',$USER);
return WSTReturn('短信发送成功!',1);
}
return $rv;
}
/**
* 手机验证码检测
* -1 错误1正确
*/
public function checkfindPhone($phoneVerify){
if(!session('findPhone.phoneVerify') || time()>floatval(session('findPhone.time'))+10*60){
return WSTReturn("校验码已失效,请重新发送!");
exit();
}
if (session('findPhone.phoneVerify') == $phoneVerify ) {
$fuserId = session('findPass.userId');
if(!empty($fuserId)){
session('REST_userId',$fuserId);
session('REST_success','1');
$rs['status'] = 1;
$rs['url'] = url('home/users/resetPass');
return $rs;
}
return WSTReturn('无效用户',-1);
}
return WSTReturn('校验码错误!',-1);
}
/**
* 发送验证邮件/找回密码
*/
public function getfindEmail(){
$code = rand(0,999999);
$sendRs = ['status'=>-1,'msg'=>'邮件发送失败'];
$tpl = WSTMsgTemplates('EMAIL_FOTGET');
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$find = ['${LOGIN_NAME}','${SEND_TIME}','${VERFIY_CODE}','${VERFIY_TIME}'];
$replace = [session('findPass.loginName'),date('Y-m-d H:i:s'),$code,30];
$sendRs = WSTSendMail(session('findPass.userEmail'),'密码重置',str_replace($find,$replace,$tpl['content']));
}
if($sendRs['status']==1){
$uId = session('findPass.userId');
session("findPass.key", $code);
// 发起重置密码的时间;
session('REST_Time',time());
return WSTReturn("发送成功",1);
}else{
return WSTReturn($sendRs['msg'],-1);
}
}
/**
* 加载登录小窗口
*/
public function toLoginBox(){
return $this->fetch('box_login');
}
/**
* 跳去修改支付密码页
*/
public function editPayPass(){
$m = new MUsers();
//获取用户信息
$userId = (int)session('WST_USER.userId');
$data = $m->getById($userId);
$this->assign('data',$data);
return $this->fetch('users/security/user_pay_pass');
}
/**
* 修改支付密码
*/
public function payPassEdit(){
$userId = (int)session('WST_USER.userId');
$m = new MUsers();
$rs = $m->editPayPass($userId);
return $rs;
}
/**
* 获取用户金额
*/
public function getUserMoney(){
$m = new MUsers();
$rs = $m->getFieldsById((int)session('WST_USER.userId'),'userMoney,lockMoney,rechargeMoney,payPwd');
$rs['isSetPayPwd'] = ($rs['payPwd']=='')?0:1;
$rs['isDraw'] = ((float)WSTConf('CONF.drawCashUserLimit')<=$rs['userMoney'])?1:0;
unset($rs['payPwd']);
return WSTReturn('',1,$rs);
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\UserScores as MUserscores;
/**
* ============================================================================
* 积分控制器
*/
class Userscores extends Base{
protected $beforeActionList = ['checkAuth'];
/**
* 查看商城消息
*/
public function index(){
$rs = model('Users')->getFieldsById((int)session('WST_USER.userId'),['userScore','userTotalScore']);
$this->assign('object',$rs);
return $this->fetch('users/userscores/list');
}
/**
* 获取数据
*/
public function pageQuery(){
$userId = (int)session('WST_USER.userId');
$data = model('UserScores')->pageQuery($userId);
return WSTReturn("", 1,$data);
}
/**
* 签到积分
*/
public function signScore(){
$m = new MUserscores();
$userId = (int)session('WST_USER.userId');
$rs = $m->signScore($userId);
return $rs;
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace wstmart\home\controller;
use wstmart\common\model\Orders as OM;
use wstmart\common\model\Users as UM;
/**
* ============================================================================
* 余额控制器
*/
class Wallets extends Base{
/**
* 生成支付代码
*/
function getWalletsUrl(){
$orderNo = input('orderNo');
$isBatch = (int)input('isBatch');
$base64 = new \org\Base64();
$key = WSTBase64url($base64->encrypt($orderNo."_".$isBatch, "WSTMart"),true);
$data = [];
$data['status'] = 1;
$data['url'] = url('home/wallets/payment','key='.$key,'html',true);
return $data;
}
/**
* 跳去支付页面
*/
public function payment(){
if((int)session('WST_USER.userId')==0){
$this->assign('message',"对不起,您尚未登录,请先登录!");
return $this->fetch('error_msg');
}
$userId = (int)session('WST_USER.userId');
$m = new UM();
$user = $m->getFieldsById($userId,["payPwd"]);
$this->assign('hasPayPwd',($user['payPwd']!="")?1:0);
$key = input('key');
$this->assign('paykey',$key);
$key = WSTBase64url($key,false);
$base64 = new \org\Base64();
$key = $base64->decrypt($key,"WSTMart");
$key = explode('_',$key);
$data = [];
$data['orderNo'] = $key[0];
$data['isBatch'] = (int)$key[1];
$data['userId'] = $userId;
$m = new OM();
$rs = $m->getOrderPayInfo($data);
if(empty($rs)){
$this->assign('message',"您的订单已支付,请勿重复支付~");
return $this->fetch('error_msg');
}else{
$this->assign('needPay',$rs['needPay']);
//获取用户钱包
$user = model('users')->getFieldsById($data['userId'],'userMoney');
$this->assign('userMoney',$user['userMoney']);
return $this->fetch('order_pay_wallets');
}
}
/**
* 钱包支付
*/
public function payByWallet(){
$m = new OM();
return $m->payByWallet();
}
}

View File

@ -0,0 +1,277 @@
<?php
namespace wstmart\home\controller;
use think\Loader;
use wstmart\common\model\Payments as M;
use wstmart\common\model\Orders as OM;
use wstmart\common\model\LogMoneys as LM;
use wstmart\common\model\LogPays as PM;
use wstmart\common\model\ChargeItems as CM;
/**
* ============================================================================
* 微信支付控制器
*/
class Weixinpays extends Base{
/**
* 初始化
*/
private $wxpayConfig;
private $wxpay;
public function _initialize() {
header ("Content-type: text/html; charset=utf-8");
Loader::import('wxpay.WxPayConf');
Loader::import('wxpay.WxQrcodePay');
$this->wxpayConfig = array();
$m = new M();
$this->wxpay = $m->getPayment("weixinpays");
$this->wxpayConfig['appid'] = $this->wxpay['appId']; // 微信公众号身份的唯一标识
$this->wxpayConfig['appsecret'] = $this->wxpay['appsecret']; // JSAPI接口中获取openid
$this->wxpayConfig['mchid'] = $this->wxpay['mchId']; // 受理商ID
$this->wxpayConfig['key'] = $this->wxpay['apiKey']; // 商户支付密钥Key
$this->wxpayConfig['notifyurl'] = url("home/weixinpays/wxNotify","",true,true);
$this->wxpayConfig['curl_timeout'] = 30;
$this->wxpayConfig['returnurl'] = "";
// 初始化WxPayConf_pub
$wxpaypubconfig = new \WxPayConf($this->wxpayConfig);
}
/**
* 获取微信URL
*/
public function getWeixinPaysURL(){
$m = new OM();
$payObj = input("payObj/s");
$pkey = "";
$data = array();
if($payObj=="recharge"){
$cm = new CM();
$itmeId = (int)input("itmeId/d");
$targetType = (int)input("targetType/d");
$targetId = (int)session('WST_USER.userId');
if($targetType==1){//商家
$targetId = (int)session('WST_USER.shopId');
}
$needPay = 0;
if($itmeId>0){
$item = $cm->getItemMoney($itmeId);
$needPay = isSet($item["chargeMoney"])?$item["chargeMoney"]:0;
}else{
$needPay = (int)input("needPay/d");
}
$data["status"] = $needPay>0?1:-1;
$pkey = $payObj."@".$targetId."@".$targetType."@".$needPay."@".$itmeId;
}else{
$userId = (int)session('WST_USER.userId');
$data = $m->checkOrderPay();
if($data["status"]==1){
$orderNo = input("orderNo/s");
$isBatch = (int)input("isBatch/d");
$pkey = $payObj."@".$userId."@".$orderNo;
if($isBatch==1){
$pkey = $pkey."@1";
}else{
$pkey = $pkey."@2";
}
}
}
$data["url"] = url('home/weixinpays/createQrcode',array("pkey"=>base64_encode($pkey)));
return $data;
}
public function createQrcode() {
$pkey = base64_decode(input("pkey"));
$pkeys = explode("@", $pkey );
$flag = true;
$needPay = 0;
$out_trade_no = 0;
$trade_no = 0;
if($pkeys[0]=="recharge"){
$needPay = (int)$pkeys[3];
$out_trade_no = WSTOrderNo();
$body = "钱包充值";
$trade_no = $out_trade_no;
}else{
if(count($pkeys)!= 4){
$this->assign('out_trade_no', "");
}else{
$userId = (int)session('WST_USER.userId');
$obj = array();
$obj["userId"] = $userId;
$obj["orderNo"] = $pkeys[2];
$obj["isBatch"] = $pkeys[3];
$m = new OM();
$order = $m->getPayOrders($obj);
$needPay = $order["needPay"];
$payRand = $order["payRand"];
$body = "支付订单费用";
$out_trade_no = $obj["orderNo"]."a".$payRand;
$trade_no = $obj["orderNo"];
}
}
if($needPay>0){
// 使用统一支付接口
$wxQrcodePay = new \WxQrcodePay ();
$wxQrcodePay->setParameter ( "body", $body ); // 商品描述
$wxQrcodePay->setParameter ( "out_trade_no", $out_trade_no ); // 商户订单号
$wxQrcodePay->setParameter ( "total_fee", $needPay * 100 ); // 总金额
$wxQrcodePay->setParameter ( "notify_url", $this->wxpayConfig['notifyurl'] ); // 通知地址
$wxQrcodePay->setParameter ( "trade_type", "NATIVE" ); // 交易类型
$wxQrcodePay->setParameter ( "attach", "$pkey" ); // 附加数据
$wxQrcodePay->SetParameter ( "input_charset", "UTF-8" );
// 获取统一支付接口结果
$wxQrcodePayResult = $wxQrcodePay->getResult ();
$code_url = '';
// 商户根据实际情况设置相应的处理流程
if ($wxQrcodePayResult ["return_code"] == "FAIL") {
// 商户自行增加处理流程
echo "通信出错:" . $wxQrcodePayResult ['return_msg'] . "<br>";
} elseif ($wxQrcodePayResult ["result_code"] == "FAIL") {
// 商户自行增加处理流程
echo "错误代码:" . $wxQrcodePayResult ['err_code'] . "<br>";
echo "错误代码描述:" . $wxQrcodePayResult ['err_code_des'] . "<br>";
} elseif ($wxQrcodePayResult ["code_url"] != NULL) {
// 从统一支付接口获取到code_url
$code_url = $wxQrcodePayResult ["code_url"];
// 商户自行增加处理流程
}
$this->assign ( 'out_trade_no', $trade_no );
$this->assign ( 'code_url', $code_url );
$this->assign ( 'wxQrcodePayResult', $wxQrcodePayResult );
$this->assign ( 'needPay', $needPay );
}else{
$flag = false;
}
if($pkeys[0]=="recharge"){
if($pkeys[2]==1){
return $this->fetch('shops/recharge/pay_step2');
}else{
return $this->fetch('users/recharge/pay_step2');
}
}else{
if($flag){
return $this->fetch('order_pay_step2');
}else{
return $this->fetch('order_pay_step3');
}
}
}
/**
* 检查支付结果
*/
public function getPayStatus() {
$trade_no = input('trade_no');
$obj = array();
$obj["userId"] = (int)session('WST_USER.userId');
$obj["transId"] = $trade_no;
$m = new PM();
$log = $m->getPayLog($obj);
$data = array("status"=>-1);
// 检查是否存在,存在说明支付成功
if(isset($log["logId"]) && $log["logId"]>0){
$m->delPayLog($obj);
$data["status"] = 1;
}else{
$data["status"] = -1;
}
return $data;
}
/**
* 微信异步通知
*/
public function wxNotify() {
// 使用通用通知接口
$wxQrcodePay = new \WxQrcodePay ();
// 存储微信的回调
$xml = file_get_contents("php://input");
$wxQrcodePay->saveData ( $xml );
// 验证签名,并回应微信。
if ($wxQrcodePay->checkSign () == FALSE) {
$wxQrcodePay->setReturnParameter ( "return_code", "FAIL" ); // 返回状态码
$wxQrcodePay->setReturnParameter ( "return_msg", "签名失败" ); // 返回信息
} else {
$wxQrcodePay->setReturnParameter ( "return_code", "SUCCESS" ); //设置返回码
}
$returnXml = $wxQrcodePay->returnXml ();
if ($wxQrcodePay->checkSign () == TRUE) {
if ($wxQrcodePay->data ["return_code"] == "FAIL") {
echo "FAIL";
} elseif ($wxQrcodePay->data ["result_code"] == "FAIL") {
echo "FAIL";
} else {
// 此处应该更新一下订单状态,商户自行增删操作
$order = $wxQrcodePay->getData ();
$trade_no = $order["transaction_id"];
$total_fee = $order ["total_fee"];
$pkey = $order ["attach"] ;
$pkeys = explode ( "@", $pkey );
$out_trade_no = 0;
$userId = 0;
if($pkeys[0]=="recharge"){//充值
$out_trade_no = $order["out_trade_no"];
$targetId = (int)$pkeys [1];
$userId = $targetId;
$targetType = (int)$pkeys [2];
$itemId = (int)$pkeys [4];
$obj = array ();
$obj["trade_no"] = $trade_no;
$obj["out_trade_no"] = $out_trade_no;
$obj["targetId"] = $targetId;
$obj["targetType"] = $targetType;
$obj["itemId"] = $itemId;
$obj["total_fee"] = (float)$total_fee/100;
$obj["payFrom"] = 'weixinpays';
// 支付成功业务逻辑
$m = new LM();
$rs = $m->complateRecharge ( $obj );
}else{//订单支付
$userId = (int)$pkeys [1];
$out_trade_no = $pkeys[2];
$isBatch = (int)$pkeys[3];
// 商户订单
$obj = array ();
$obj["trade_no"] = $trade_no;
$obj["out_trade_no"] = $out_trade_no;
$obj["isBatch"] = $isBatch;
$obj["total_fee"] = (float)$total_fee/100;
$obj["userId"] = $userId;
$obj["payFrom"] = 'weixinpays';
// 支付成功业务逻辑
$m = new OM();
$rs = $m->complatePay ( $obj );
}
if($rs["status"]==1){
$data = array();
$data["userId"] = $userId;
$data["transId"] = $out_trade_no;
$m = new PM();
$m->addPayLog($data);
echo "SUCCESS";
}else{
echo "FAIL";
}
}
}else{
echo "FAIL";
}
}
/**
* 检查支付结果
*/
public function paySuccess() {
return $this->fetch('order_pay_step3');
}
}