You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
BIN
hyhproject/app/controller/.DS_Store
vendored
Executable file
BIN
hyhproject/app/controller/.DS_Store
vendored
Executable file
Binary file not shown.
BIN
hyhproject/app/controller/._.DS_Store
Executable file
BIN
hyhproject/app/controller/._.DS_Store
Executable file
Binary file not shown.
622
hyhproject/app/controller/Alipays.php
Executable file
622
hyhproject/app/controller/Alipays.php
Executable file
@ -0,0 +1,622 @@
|
||||
<?php
|
||||
|
||||
namespace wstmart\app\controller;
|
||||
|
||||
use think\Loader;
|
||||
|
||||
use wstmart\common\model\Payments as M;
|
||||
|
||||
use wstmart\app\model\Orders as OM;
|
||||
|
||||
use wstmart\common\model\LogPayParams as PM;
|
||||
|
||||
use wstmart\common\model\ChargeItems as CM;
|
||||
|
||||
use wstmart\common\model\LogMoneys as LM;
|
||||
|
||||
/**
|
||||
|
||||
* ============================================================================
|
||||
|
||||
* 阿里支付控制器
|
||||
|
||||
*/
|
||||
|
||||
class Alipays extends Base{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 初始化
|
||||
|
||||
*/
|
||||
|
||||
private $alipayConfig;
|
||||
|
||||
public function _initialize() {
|
||||
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
|
||||
Loader::import ( 'app_alipay.aop.AopClient' );
|
||||
|
||||
Loader::import ( 'app_alipay.aop.request.AlipayTradeAppPayRequest' );
|
||||
|
||||
$m = new M();
|
||||
|
||||
$payment = $m->getPayment("app_alipays");
|
||||
|
||||
$this->alipayConfig = array(
|
||||
|
||||
'app_id' =>trim($payment['appId']),
|
||||
|
||||
'rsaPrivateKey' =>trim($payment['rsaPrivateKey']),//'请填写开发者私钥去头去尾去回车,一行字符串'
|
||||
|
||||
'alipayrsaPublicKey' =>trim($payment['alipayrsaPublicKey']),//公钥
|
||||
|
||||
'format' =>'json',//格式
|
||||
|
||||
'charset' =>'UTF-8',
|
||||
|
||||
'signType' =>'RSA2',
|
||||
|
||||
'seller_email'=>'ect@ect99.com'
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 支付宝支付跳转方法
|
||||
|
||||
*/
|
||||
|
||||
public function toAliPay(){
|
||||
|
||||
// echo "<span style='font-size:40px;'>暂停APP支付,请选择WAP端支付宝支付</span>";
|
||||
|
||||
// return;
|
||||
|
||||
$payObj = input("payObj/s");
|
||||
|
||||
|
||||
|
||||
$call_back_url = "";
|
||||
|
||||
$notify_url = "";
|
||||
|
||||
$subject = "";
|
||||
|
||||
$total_fee = 0;
|
||||
|
||||
$transId = 0;
|
||||
|
||||
$userId = 0;
|
||||
|
||||
$payParams = array();
|
||||
|
||||
if($payObj=="recharge"){//充值
|
||||
|
||||
$itemId = (int)input("itemId/d");
|
||||
|
||||
$orderAmount = 0;
|
||||
|
||||
if($itemId>0){
|
||||
|
||||
$cm = new CM();
|
||||
|
||||
$item = $cm->getItemMoney($itemId);
|
||||
|
||||
$total_fee = isSet($item["chargeMoney"])?$item["chargeMoney"]:0;
|
||||
|
||||
}else{
|
||||
|
||||
$total_fee = (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;
|
||||
|
||||
}
|
||||
|
||||
$userId = $targetId;
|
||||
|
||||
$out_trade_no = WSTOrderNo();
|
||||
|
||||
$transId = $out_trade_no;
|
||||
|
||||
$payParams["targetId"] = $targetId;
|
||||
|
||||
$payParams["targetType"] = $targetType;
|
||||
|
||||
$payParams["itemId"] = $itemId;
|
||||
|
||||
$payParams["payObj"] = $payObj;
|
||||
|
||||
|
||||
|
||||
//$call_back_url = url("app/users/index","",true,true);
|
||||
|
||||
$notify_url = url("app/alipays/aliNotify","",true,true);
|
||||
|
||||
$subject = '钱包充值';
|
||||
|
||||
}else{
|
||||
|
||||
$orderNo = input('orderNo');
|
||||
|
||||
$isBatch = (int)input('isBatch');
|
||||
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
|
||||
$m = new OM();
|
||||
|
||||
$obj = array();
|
||||
|
||||
$obj["userId"] = $userId;
|
||||
|
||||
$obj["orderNo"] = input("orderNo/s");
|
||||
|
||||
$obj["isBatch"] = (int)input("isBatch/d");
|
||||
|
||||
$rs = $m->getOrderPayInfo($obj);
|
||||
|
||||
if(empty($rs)){
|
||||
|
||||
echo "<span style='font-size:40px;'>找不到此订单!</span>";
|
||||
|
||||
return;
|
||||
|
||||
}else{
|
||||
|
||||
$m = new M();
|
||||
|
||||
$om = new OM();
|
||||
|
||||
$data = $om->checkOrderPay($obj);
|
||||
|
||||
if($data["status"]==-1){
|
||||
|
||||
echo "<span style='font-size:40px;'>您的订单已支付,不要重复支付!</span>";
|
||||
|
||||
return;
|
||||
|
||||
}else if($data["status"]==-2){
|
||||
|
||||
echo "<span style='font-size:40px;'>您的订单因商品库存不足,不能支付!</span>";
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$order = $om->getPayOrders($obj);
|
||||
|
||||
$total_fee = $order["needPay"];
|
||||
|
||||
$payRand = $order["payRand"];
|
||||
|
||||
$out_trade_no = $obj["orderNo"]."a".$payRand;
|
||||
|
||||
$transId = $obj["orderNo"];
|
||||
|
||||
|
||||
|
||||
$payParams["userId"] = $userId;
|
||||
|
||||
$payParams["isBatch"] = $isBatch;
|
||||
|
||||
$payParams["orderNo"] = $orderNo;
|
||||
|
||||
|
||||
|
||||
//$call_back_url = url("app/orders/index","",true,true);
|
||||
|
||||
$notify_url = url("app/alipays/aliNotify","",true,true);
|
||||
|
||||
$subject = '支付购买商品费用';
|
||||
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
$data["userId"] = $userId;
|
||||
|
||||
$data["transId"] = $transId;
|
||||
|
||||
$data["paramsVa"] = json_encode($payParams);
|
||||
|
||||
$data["payFrom"] = 'alipays';
|
||||
|
||||
$m = new PM();
|
||||
|
||||
$m->addPayLog($data);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//建立请求
|
||||
|
||||
$aop = new \AopClient;
|
||||
|
||||
$aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
|
||||
|
||||
$aop->appId = $this->alipayConfig['app_id'];
|
||||
|
||||
$aop->rsaPrivateKey = $this->alipayConfig['rsaPrivateKey'];
|
||||
|
||||
$aop->alipayrsaPublicKey = $this->alipayConfig['alipayrsaPublicKey'];
|
||||
|
||||
$aop->apiVersion = '1.0';
|
||||
|
||||
$aop->signType = "RSA2";
|
||||
|
||||
$aop->postCharset = $this->alipayConfig['charset'];
|
||||
|
||||
$aop->format = $this->alipayConfig['format'];
|
||||
|
||||
//$aop->charset = $this->alipayConfig['charset'];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
|
||||
|
||||
$request = new \AlipayTradeAppPayRequest();
|
||||
|
||||
// 异步通知地址
|
||||
|
||||
//$notify_url = urlencode($notify_url);
|
||||
|
||||
// 订单标题
|
||||
|
||||
$subject = $subject;
|
||||
|
||||
// 订单详情
|
||||
|
||||
$body = $subject;
|
||||
|
||||
//SDK已经封装掉了公共参数,这里只需要传入业务参数
|
||||
|
||||
$bizcontent = "{\"body\":\"".$body."\","
|
||||
|
||||
. "\"subject\": \"".$subject."\","
|
||||
|
||||
. "\"out_trade_no\": \"".$out_trade_no."\","
|
||||
|
||||
. "\"timeout_express\": \"30m\","
|
||||
|
||||
. "\"total_amount\": \"".$total_fee."\","
|
||||
|
||||
. "\"product_code\":\"QUICK_MSECURITY_PAY\""
|
||||
|
||||
. "}";
|
||||
|
||||
$request->setNotifyUrl($notify_url);
|
||||
|
||||
$request->setBizContent($bizcontent);
|
||||
|
||||
//这里和普通的接口调用不同,使用的是sdkExecute
|
||||
|
||||
$response = $aop->sdkExecute($request);
|
||||
|
||||
// 注意:这里不需要使用htmlspecialchars进行转义,直接返回即可
|
||||
|
||||
echo $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 验签
|
||||
|
||||
* @param [type] $postParams [description]
|
||||
|
||||
* @return [type] [description]
|
||||
|
||||
*/
|
||||
|
||||
public function checkSign($postParams){
|
||||
|
||||
|
||||
|
||||
$aop = new \AopClient;
|
||||
|
||||
$aop->alipayrsaPublicKey = $this->alipayConfig['alipayrsaPublicKey'];
|
||||
|
||||
$flag = $aop->rsaCheckV1($postParams, NULL, "RSA2");
|
||||
|
||||
return $flag;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 服务器异步通知页面方法
|
||||
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
function alinotify() {
|
||||
|
||||
//验签通过后再实现业务逻辑,比如修改订单表中的支付状态。
|
||||
|
||||
/**
|
||||
|
||||
①验签通过后核实如下参数trade_status、out_trade_no、total_amount、seller_id
|
||||
|
||||
②修改订单表
|
||||
|
||||
**/
|
||||
// if(!isset($_POST['app_id'])){
|
||||
// $_POST = $_GET;
|
||||
// }
|
||||
if(!$this->checkSign($_POST)){//验签
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//验证app_id是否为该商户本身
|
||||
|
||||
if($this->alipayConfig['app_id'] != $_POST['app_id']){
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方
|
||||
|
||||
if(isset($_POST['seller_email']) && ($_POST['seller_email'] != $_POST['seller_email'])){
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
$out_trade_no = $_POST['out_trade_no'];//获取交易号
|
||||
|
||||
$tradeNo = explode("a",$out_trade_no);//实际订单号
|
||||
|
||||
$om = new OM();
|
||||
|
||||
//商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号
|
||||
|
||||
$orderInfo = $om->getOrderByOrderNo($tradeNo['0'],'needPay,isPay');//取订单信息;
|
||||
|
||||
if(empty($orderInfo)){
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额)
|
||||
|
||||
// if ($_POST['total_amount'] != $orderInfo['needPay']){
|
||||
|
||||
|
||||
|
||||
// return false;
|
||||
|
||||
// }
|
||||
|
||||
if(0==$orderInfo["isPay"] && ($_POST['trade_status']=="TRADE_SUCCESS" || $_POST['trade_status']=="TRADE_FINISHED")){
|
||||
|
||||
//处理订单
|
||||
|
||||
$obj["trade_no"] = $_POST['trade_no'];//支付宝交易号
|
||||
|
||||
$obj["out_trade_no"] = $tradeNo[0];//实际订单号
|
||||
|
||||
$obj["payFrom"] = 'alipays';
|
||||
|
||||
$obj["total_fee"] = $_POST['total_amount'];//订单金额
|
||||
|
||||
|
||||
|
||||
$m = new PM();
|
||||
|
||||
$payParams = $m->getPayLog(["transId"=>$obj["out_trade_no"]]);
|
||||
|
||||
if(isSet($payParams["payObj"]) && $payParams["payObj"]=='recharge'){
|
||||
|
||||
|
||||
|
||||
$obj["targetId"] = $payParams["targetId"];
|
||||
|
||||
$obj["targetType"] = $payParams["targetType"];
|
||||
|
||||
$obj["itemId"] = $payParams["itemId"];;
|
||||
|
||||
// 支付成功业务逻辑
|
||||
|
||||
$m = new LM();
|
||||
|
||||
$rs = $m->complateRecharge ( $obj );
|
||||
|
||||
}else{
|
||||
|
||||
//$payFrom = $om->getOrderPayFrom($tradeNo[0]);
|
||||
|
||||
$obj["userId"] = $payParams["userId"];
|
||||
|
||||
$obj["isBatch"] = $payParams["isBatch"];
|
||||
|
||||
//支付成功业务逻辑
|
||||
|
||||
$rs = $om->complatePay($obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($rs["status"]==1){
|
||||
|
||||
echo 'success';// 请不要修改或删除
|
||||
|
||||
}else{
|
||||
|
||||
echo 'fail';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//echo "success";// 请不要修改或删除
|
||||
|
||||
// // 计算得出通知验证结果
|
||||
|
||||
// $alipayNotify = new \AlipayNotify ( $this->alipayConfig );
|
||||
|
||||
// $verify_result = $alipayNotify->verifyNotify ();
|
||||
|
||||
|
||||
|
||||
// if ($verify_result) {
|
||||
|
||||
// $notify_data = $_POST['notify_data'];
|
||||
|
||||
// // 获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
|
||||
|
||||
// // 解析notify_data
|
||||
|
||||
// // 注意:该功能PHP5环境及以上支持,需开通curl、SSL等PHP配置环境。建议本地调试时使用PHP开发软件
|
||||
|
||||
// $doc = new \DOMDocument ();
|
||||
|
||||
// $doc->loadXML ( $notify_data );
|
||||
|
||||
// if (! empty ( $doc->getElementsByTagName ( "notify" )->item ( 0 )->nodeValue )) {
|
||||
|
||||
// // 交易号
|
||||
|
||||
// $trade_no = $doc->getElementsByTagName ( "trade_no" )->item ( 0 )->nodeValue;
|
||||
|
||||
// // 商户订单号
|
||||
|
||||
// $out_trade_no = $doc->getElementsByTagName ( "out_trade_no" )->item ( 0 )->nodeValue;
|
||||
|
||||
|
||||
|
||||
// $total_fee = $doc->getElementsByTagName( "total_fee" )->item(0)->nodeValue;
|
||||
|
||||
// // 支付宝交易号
|
||||
|
||||
// $trade_no = $doc->getElementsByTagName ( "trade_no" )->item ( 0 )->nodeValue;
|
||||
|
||||
// // 交易状态
|
||||
|
||||
// $trade_status = $doc->getElementsByTagName ( "trade_status" )->item ( 0 )->nodeValue;
|
||||
|
||||
// if ($trade_status == 'TRADE_FINISHED' OR $trade_status == 'TRADE_SUCCESS') {
|
||||
|
||||
// $obj["trade_no"] = $trade_no;
|
||||
|
||||
// $tradeNo = explode("a",$out_trade_no);
|
||||
|
||||
|
||||
|
||||
// $obj["out_trade_no"] = $tradeNo[0];
|
||||
|
||||
// $obj["payFrom"] = 'alipays';
|
||||
|
||||
// $obj["total_fee"] = $total_fee;
|
||||
|
||||
|
||||
|
||||
// $m = new PM();
|
||||
|
||||
// $payParams = $m->getPayLog(["transId"=>$obj["out_trade_no"]]);
|
||||
|
||||
// if(isSet($payParams["payObj"]) && $payParams["payObj"]=='recharge'){
|
||||
|
||||
|
||||
|
||||
// $obj["targetId"] = $payParams["targetId"];
|
||||
|
||||
// $obj["targetType"] = $payParams["targetType"];
|
||||
|
||||
// $obj["itemId"] = $payParams["itemId"];;
|
||||
|
||||
// // 支付成功业务逻辑
|
||||
|
||||
// $m = new LM();
|
||||
|
||||
// $rs = $m->complateRecharge ( $obj );
|
||||
|
||||
// }else{
|
||||
|
||||
// //$payFrom = $om->getOrderPayFrom($tradeNo[0]);
|
||||
|
||||
// $obj["userId"] = $payParams["userId"];
|
||||
|
||||
// $obj["isBatch"] = $payParams["isBatch"];
|
||||
|
||||
// //支付成功业务逻辑
|
||||
|
||||
// $rs = $om->complatePay($obj);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// if($rs["status"]==1){
|
||||
|
||||
// echo 'success';
|
||||
|
||||
// }else{
|
||||
|
||||
// echo 'fail';
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// echo "success"; // 请不要修改或删除
|
||||
|
||||
// }
|
||||
|
||||
// } else {
|
||||
|
||||
// // 验证失败
|
||||
|
||||
// echo "fail";
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
130
hyhproject/app/controller/Appport.php
Executable file
130
hyhproject/app/controller/Appport.php
Executable file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use think\Loader;
|
||||
use wstmart\app\model\AppPort as M;
|
||||
use wstmart\common\model\LogPayParams as PM;
|
||||
use wstmart\common\model\ChargeItems as CM;
|
||||
use wstmart\common\model\LogMoneys as LM;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 阿里支付控制器
|
||||
*/
|
||||
class Appport extends Base{
|
||||
/*
|
||||
* app新版首页轮播图
|
||||
* */
|
||||
public function appBanner(){
|
||||
$m=new M();
|
||||
$result=$m->appBanner();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/**
|
||||
* app新版首页桔子头条接口
|
||||
*/
|
||||
public function appNews(){
|
||||
$m = new M();
|
||||
$result = $m->appNews();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/**
|
||||
* app新版首页桔子头条列表页接口
|
||||
*/
|
||||
public function appNewsLists(){
|
||||
$m = new M();
|
||||
$result = $m->appNewsLists();
|
||||
dump($result);
|
||||
//exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/**
|
||||
* app新版桔子头条分类接口
|
||||
*/
|
||||
public function appNewsClass(){
|
||||
$m = new M();
|
||||
$result = $m->appNewsClass();
|
||||
dump($result);
|
||||
//exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/**
|
||||
* app新版桔子头条详情页接口
|
||||
*/
|
||||
public function appNewsDetail(){
|
||||
$m = new M();
|
||||
$result = $m->appNewsDetail();
|
||||
dump($result);
|
||||
//exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版秒杀接口
|
||||
* */
|
||||
public function appSecKill(){
|
||||
$m=new M();
|
||||
$result=$m->appSecKill();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版ect专区/活动区 图片接口
|
||||
* */
|
||||
public function appEctAct(){
|
||||
$m=new M();
|
||||
$result=$m->appEctAct();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版品牌热卖接口
|
||||
* */
|
||||
public function appBrands(){
|
||||
$m=new M();
|
||||
$result=$m->appBrands();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版居家好帮手广告位接口
|
||||
* */
|
||||
public function appJadvertis(){
|
||||
$m=new M();
|
||||
$result=$m->appJadvertis();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版潮流先锋广告位接口
|
||||
* */
|
||||
public function appCadvertis(){
|
||||
$m=new M();
|
||||
$result=$m->appCadvertis();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版食品超市广告位接口
|
||||
* */
|
||||
public function appSadvertis(){
|
||||
$m=new M();
|
||||
$result=$m->appSadvertis();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app新版家电馆广告位接口
|
||||
* */
|
||||
public function appDadvertis(){
|
||||
$m=new M();
|
||||
$result=$m->appDadvertis();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
/*
|
||||
* app为你推荐接口
|
||||
/*/
|
||||
public function recommend(){
|
||||
$m=new M();
|
||||
$result=$m->recommend();
|
||||
//dump($result);
|
||||
exit(json_encode(WSTReturn('',1,$result)));
|
||||
}
|
||||
}
|
103
hyhproject/app/controller/Areas.php
Executable file
103
hyhproject/app/controller/Areas.php
Executable file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Areas as M;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 地区控制器
|
||||
*/
|
||||
class Areas extends Base{
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
public function listQuery(){
|
||||
$m = new M();
|
||||
$rs = $m->listQuery();
|
||||
exit(jsonReturn('', 1,$rs));
|
||||
}
|
||||
// CREATE TABLE `hyh_user_trees` (
|
||||
// `id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
// `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
|
||||
// `pid` int(11) NOT NULL DEFAULT '0' COMMENT '父ID',
|
||||
// `bid` int(11) NOT NULL DEFAULT '0' COMMENT '家族ID',
|
||||
// `lft` int(11) NOT NULL DEFAULT '1' COMMENT '左节点',
|
||||
// `rgt` int(11) NOT NULL DEFAULT '2' COMMENT '右节点',
|
||||
// `t_level` smallint(6) NOT NULL DEFAULT '0' COMMENT '层级',
|
||||
// `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '时间',
|
||||
// PRIMARY KEY (`id`)
|
||||
// ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
|
||||
public function tmp(){
|
||||
return;
|
||||
set_time_limit(0);
|
||||
$user_list = Db::table('rd_users')->where('1=1')->field('user_id,first_leader,shop_id')->order('user_id asc')->select();
|
||||
foreach ($user_list as $v) {
|
||||
$u_info = Db::table('rd_users')->where('user_id='.$v['user_id'])->field('user_id,first_leader,shop_id')->find();
|
||||
$userId = $u_info['shop_id'];
|
||||
if($userId){
|
||||
if($u_info['first_leader']){
|
||||
$p_info = Db::table('rd_users')->where('user_id='.$u_info['first_leader'])->field('user_id,shop_id')->find();
|
||||
$pid = $p_info['shop_id'];
|
||||
}else{
|
||||
$pid = 0;
|
||||
}
|
||||
ectLog($userId,10,1,'注册送ect',['userECT'=>['exp','userECT+10']]);
|
||||
if($pid){
|
||||
ectLog($pid,5,1,'推荐送ect',['userECT'=>['exp','userECT+5']]);
|
||||
}
|
||||
$this->create_tree($userId,$pid,0);
|
||||
}
|
||||
|
||||
}
|
||||
die('ok');
|
||||
}
|
||||
function create_tree($uid,$pid){
|
||||
if(!$uid) return;
|
||||
if(Db::name('user_trees')->where(array('uid'=>$uid))->find()) return;//树里有
|
||||
if($pid){
|
||||
$p_info = Db::name('user_trees')->where(array('uid'=>$pid))->field('bid,t_level')->find();
|
||||
if($p_info['t_level']){
|
||||
$t_level = $p_info['t_level'] + 1;
|
||||
}else{
|
||||
$t_level = 2;
|
||||
}
|
||||
if($p_info['bid']){
|
||||
$bid = $p_info['bid'];
|
||||
}else{
|
||||
$bid = $pid;
|
||||
}
|
||||
|
||||
}else{
|
||||
$bid = $uid;
|
||||
$t_level = 1;
|
||||
}
|
||||
$set = array(
|
||||
'uid'=>$uid,
|
||||
'pid'=>$pid,
|
||||
'bid'=>$bid,
|
||||
't_level'=>$t_level,
|
||||
'update_time'=>time()
|
||||
);
|
||||
Db::name('user_trees')->insert($set);
|
||||
//获取家族树最顶级节点,重建树
|
||||
$this->rebuild_tree($bid,1);//重建树,建立有左右值的数据表,对整个结构重新进行一次编号
|
||||
|
||||
}
|
||||
function rebuild_tree($root, $left) {
|
||||
// the right value of this node is the left value + 1
|
||||
$right = $left+1;
|
||||
// get all children of this node
|
||||
$trees = Db::name('user_trees')->where(array('pid'=>$root))->field('uid')->select();
|
||||
if($trees){
|
||||
foreach ($trees as $k => $v) {
|
||||
$right = $this->rebuild_tree($v['uid'], $right);
|
||||
}
|
||||
}
|
||||
$set = array(
|
||||
'lft' => $left,
|
||||
'rgt' => $right,
|
||||
);
|
||||
Db::name('user_trees')->where(array('uid'=>$root))->update($set);
|
||||
// return the right value of this node + 1
|
||||
return $right + 1;
|
||||
}
|
||||
}
|
64
hyhproject/app/controller/Articles.php
Executable file
64
hyhproject/app/controller/Articles.php
Executable file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Tags as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 地区控制器
|
||||
*/
|
||||
class Articles extends Base{
|
||||
/**
|
||||
* 获取首页惠员快报
|
||||
*/
|
||||
public function getIndexNews(){
|
||||
$m = new M();
|
||||
$rs = $m->listArticle('new',10,86400);
|
||||
exit(jsonReturn('', 1,$rs));
|
||||
}
|
||||
/**
|
||||
* 获取惠员快报列表
|
||||
*/
|
||||
public function getNewsList(){
|
||||
$m = new M();
|
||||
$rs = $m->newArticle();
|
||||
exit(jsonReturn('', 1,$rs));
|
||||
}
|
||||
//添加显示会员快报 make cheng 20180227
|
||||
public function showArticle(){
|
||||
$m = new M();
|
||||
$article = $m->showArticle();
|
||||
exit(jsonReturn('', 1,$article));
|
||||
}
|
||||
|
||||
/**
|
||||
*桔子头条分类
|
||||
*/
|
||||
public function orange(){
|
||||
$m = new M();
|
||||
$orange = $m->orangeType();
|
||||
// print_r($orange);die;
|
||||
exit(json_encode(WSTReturn('ok',1,$orange)));
|
||||
}
|
||||
/**
|
||||
* 桔子头条文章
|
||||
*/
|
||||
public function headLine(){
|
||||
$catId = (int)input('catId');
|
||||
// $catId = 61;
|
||||
$m = new M();
|
||||
$clog = $m->clog($catId);
|
||||
// print_r($clog);die;
|
||||
exit(json_encode(WSTReturn('ok',1,$clog)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 桔子头条文章详情
|
||||
*/
|
||||
public function detail(){
|
||||
$articleId = (int)input('articleId');
|
||||
// $articleId = '113';
|
||||
$m = new M();
|
||||
$detail = $m->detail($articleId);
|
||||
// print_r($detail);die;
|
||||
exit(json_encode(WSTReturn('ok',1,$detail)));
|
||||
}
|
||||
}
|
560
hyhproject/app/controller/Auth.php
Executable file
560
hyhproject/app/controller/Auth.php
Executable file
@ -0,0 +1,560 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Auth as M;
|
||||
use wstmart\common\model\AuthFamily as FM;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 认证控制器
|
||||
*/
|
||||
class Auth extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取认证信息
|
||||
*/
|
||||
public function getAuthInfo(){
|
||||
$m = new M();
|
||||
$isCompany = (int)input('post.isCompany');//1是合作认证
|
||||
if(1 == $isCompany){
|
||||
$m->setTable('auth_company');
|
||||
}
|
||||
$authInfo = $m->getInfo(['userId'=>$this->getUserId()],'*');
|
||||
exit(jsonReturn('',1,$authInfo));
|
||||
}
|
||||
/**
|
||||
* 添加/编辑认证信息
|
||||
*/
|
||||
public function setAuthInfo(){
|
||||
$m = new M();
|
||||
$isCompany = (int)input('post.isCompany');//1是合作认证
|
||||
$data = input('post.');
|
||||
unset($data['headImgTag']);
|
||||
unset($data['accountBookImgTag']);
|
||||
$userId = $this->getUserId();
|
||||
if(1 == $isCompany){
|
||||
if($this->user['authType'] == 1) exit(jsonReturn('没有权限!'));
|
||||
|
||||
$m->setTable('auth_personal');
|
||||
if($m->getField(['status'=>0,'userId'=>$userId],'id')){
|
||||
exit(jsonReturn('当前账户已申请个人认证,请等待审核'));
|
||||
}
|
||||
$m->setTable('auth_company');
|
||||
$validate = \think\Loader::validate('Auth');
|
||||
if(!$validate->scene('company')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
}else{
|
||||
if($this->user['authType'] == 2) exit(jsonReturn('没有权限!'));
|
||||
$m->setTable('auth_company');
|
||||
if($m->getField(['status'=>0,'userId'=>$userId],'id')){
|
||||
exit(jsonReturn('当前账户已申请合作认证,请等待审核'));
|
||||
}
|
||||
$m->setTable('auth_personal');
|
||||
$validate = \think\Loader::validate('Auth');
|
||||
if(!$validate->scene('personal')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
$fm = new FM();
|
||||
if($fm->getInfo(['familyIdCard'=>$data['householdIdCard']],'id')){
|
||||
exit(jsonReturn('该身份证已报备,请更换'));
|
||||
}
|
||||
}
|
||||
$isUpdate = 0;
|
||||
$authId = 0;
|
||||
$data['userId'] = $userId;
|
||||
$authInfo = $m->getInfo(['userId'=>$userId],'id,status');
|
||||
if($authInfo){
|
||||
if(!empty($data['authId'])){//更新状态
|
||||
$authId = $authInfo['id'];
|
||||
if($authId == $data['authId']){//更新
|
||||
$payPwd = $data['payPwd'];
|
||||
if(md5($payPwd) != $this->user['payPwd']){
|
||||
exit(jsonReturn('操作密码错误'));
|
||||
}
|
||||
$isUpdate = 1;
|
||||
if(1 == $authInfo['status']) {
|
||||
$data['status'] = 1;
|
||||
unset($data['householdIdCard']);//成功不可以更改身份证号
|
||||
}else{
|
||||
$data['status'] = 0;//拒绝时
|
||||
}
|
||||
|
||||
}else{
|
||||
exit(jsonReturn('没有权限!'));
|
||||
}
|
||||
}else{
|
||||
exit(jsonReturn('请不要重复提交'));
|
||||
}
|
||||
}else{
|
||||
$userPhone = session('Reg_UserPhone');
|
||||
if(!$userPhone){
|
||||
exit(jsonReturn('操作超时,请重试!'));
|
||||
}
|
||||
$verify = session('RegCode_UserPhone');
|
||||
$startTime = (int)session('RegCode_UserPhone_Time');
|
||||
if((time()-$startTime)>120){
|
||||
exit(jsonReturn('验证码已超过有效期,请重新发送!'));
|
||||
}
|
||||
$mobileCode = $data['mobileCode'];
|
||||
if($mobileCode=="" || $verify != $mobileCode){
|
||||
exit(jsonReturn('短信验证码错误!'));
|
||||
}
|
||||
//$loginName = WSTRandomLoginName($log
|
||||
$data['status'] = 0;
|
||||
}
|
||||
|
||||
unset($data['authId']);
|
||||
unset($data['mobileCode']);
|
||||
unset($data['isCompany']);
|
||||
unset($data['payPwd']);
|
||||
if($isUpdate){
|
||||
$isSuccess = $m->updateInfo(['id'=>$authId],$data);
|
||||
}else{
|
||||
$isSuccess = $m->insertInfo($data);
|
||||
}
|
||||
if(false !== $isSuccess){
|
||||
session('Reg_UserPhone',null);
|
||||
$userPhone = getAdminPhone();
|
||||
$tpl = WSTMsgTemplates('PHONE_USER_UPDATE_NOTICE');
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['name'=>$this->user['loginName']]];
|
||||
$m = Model('common/LogSms');
|
||||
$rv = $m->sendSMS(0,$userPhone,$params,'PHONE_USER_UPDATE_NOTICE',0);
|
||||
}
|
||||
exit(jsonReturn('提交成功,请等待系统审核',1));
|
||||
}else{
|
||||
exit(jsonReturn('操作失败,请重试'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
public function getPhoneCode(){
|
||||
$userPhone = input("post.userPhone");
|
||||
if($this->user['userPhone'] && $this->user['userPhone'] != $userPhone){
|
||||
exit(jsonReturn("手机号错误!"));
|
||||
}
|
||||
$rs = array();
|
||||
if(!WSTIsPhone($userPhone)){
|
||||
exit(jsonReturn("手机号格式不正确!"));
|
||||
}
|
||||
$m = Model('common/Users');
|
||||
$rs = $m->checkUserPhone($userPhone,$this->getUserId());
|
||||
if($rs["status"]!=1){
|
||||
exit(jsonReturn($rs['msg']));
|
||||
}
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$tpl = WSTMsgTemplates('PHONE_USER_AUTH_NOTICE');
|
||||
$rv['status'] = -1;
|
||||
$rv['msg'] = '发送失败';
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['code'=>$phoneVerify]];
|
||||
$m = Model('common/LogSms');
|
||||
$rv = $m->sendSMS(0,$userPhone,$params,'PHONE_USER_AUTH_NOTICE',$phoneVerify);
|
||||
}
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
session('Reg_UserPhone',$userPhone);
|
||||
session('RegCode_UserPhone',$phoneVerify);
|
||||
session('RegCode_UserPhone_Time',time());
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 获取亲人报备列表
|
||||
*/
|
||||
public function getAuthFamilyReportSelect(){
|
||||
$m = new FM();
|
||||
$authInfo = $m->getList(['userId'=>$this->getUserId()],'*');
|
||||
exit(jsonReturn('',1,$authInfo));
|
||||
}
|
||||
/**
|
||||
* 获取亲人报备信息
|
||||
*/
|
||||
public function getAuthFamilyReportInfo(){
|
||||
$m = new FM();
|
||||
$id = (int)input('post.id');
|
||||
$authInfo = $m->getInfo(['userId'=>$this->getUserId(),'id'=>$id],'*');
|
||||
exit(jsonReturn('',1,$authInfo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加/编辑亲人报备信息
|
||||
*/
|
||||
public function setAuthFamilyReport(){
|
||||
$m = new FM();
|
||||
$data = input('post.');
|
||||
$validate = \think\Loader::validate('Auth');
|
||||
if(!$validate->scene('report')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
$userId = $this->getUserId();
|
||||
$data['userId'] = $userId;
|
||||
if(!empty($data['id'])){//更新状态
|
||||
$id = $data['id'];
|
||||
unset($data['id']);
|
||||
$authInfo = $m->getInfo(['userId'=>$userId,'id'=>$id],'id');
|
||||
if(!$authInfo){
|
||||
exit(jsonReturn('未找到此信息'));
|
||||
}
|
||||
$isSuccess = $m->updateInfo(['id'=>$id],$data);
|
||||
}else{
|
||||
$isSuccess = $m->insertInfo($data);
|
||||
}
|
||||
if($isSuccess){
|
||||
exit(jsonReturn('提交成功',1));
|
||||
}else{
|
||||
exit(jsonReturn('操作失败,请重试'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取亲人认证列表
|
||||
*/
|
||||
public function getAuthFamilyPersonalSelect(){
|
||||
$m = new FM();
|
||||
$m->setTable('auth_family_personal');
|
||||
$authInfo = $m->getSelect(['userId'=>$this->getUserId()],'*');
|
||||
exit(jsonReturn('',1,$authInfo));
|
||||
}
|
||||
/**
|
||||
* 获取亲人认证信息
|
||||
*/
|
||||
public function getAuthFamilyPersonalInfo(){
|
||||
$m = new FM();
|
||||
$m->setTable('auth_family_personal');
|
||||
$id = (int)input('post.id');
|
||||
$authInfo = $m->getInfo(['userId'=>$this->getUserId(),'id'=>$id],'*');
|
||||
exit(jsonReturn('',1,$authInfo));
|
||||
}
|
||||
/**
|
||||
* 获取亲人认证信息
|
||||
*/
|
||||
public function getAuthInfoByMobile(){
|
||||
$m = new M();
|
||||
//$isPartner = (int)input('post.isPartner');
|
||||
// if(1 == $isPartner){//合作认证
|
||||
// $userPhone = session('partner_UserPhone');
|
||||
// $verify = session('partnerCode_UserPhone');
|
||||
// $startTime = (int)session('partner_UserPhone_Time');
|
||||
// }else{
|
||||
$userPhone = session('auth_UserPhone');
|
||||
$verify = session('authCode_UserPhone');
|
||||
$startTime = (int)session('auth_UserPhone_Time');
|
||||
//}
|
||||
|
||||
if(!$userPhone){
|
||||
exit(jsonReturn('操作超时,请重试!'));
|
||||
}
|
||||
if((time()-$startTime)>1200){
|
||||
exit(jsonReturn('验证码已超过有效期,请重新发送!'));
|
||||
}
|
||||
$mobileCode = input('post.mobileCode');
|
||||
if($mobileCode=="" || $verify != $mobileCode){
|
||||
exit(jsonReturn('短信验证码错误!'));
|
||||
}
|
||||
session('auth_ok',1);
|
||||
$authInfo = $m->getAuthInfoByMobile($userPhone);
|
||||
exit(json_encode($authInfo));
|
||||
}
|
||||
/**
|
||||
* 删除报备或认证信息
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function delAuthFamily(){
|
||||
$m = new FM();
|
||||
$payPwd = input("post.payPwd");
|
||||
if(md5($payPwd) != $this->user['payPwd']){
|
||||
exit(jsonReturn('操作密码错误'));
|
||||
}
|
||||
$id = input("post.id");
|
||||
$isReport = (int)input('post.isReport');//0是亲人认证,1是亲人报备
|
||||
if(0 == $isReport){
|
||||
$m->setTable('auth_family_personal');
|
||||
}
|
||||
$rs = $m->updateInfo(['userId'=>$this->getUserId(),'id'=>$id],['dataFlag'=>-1]);
|
||||
if(false !== $rs){
|
||||
exit(jsonReturn('成功',1));
|
||||
}
|
||||
exit(jsonReturn('失败,请重试',1));
|
||||
}
|
||||
/**
|
||||
* 获取亲人验证码
|
||||
*/
|
||||
public function getFamilyPhoneCode(){
|
||||
if($this->user['authType'] == 2) exit(jsonReturn('没有权限!'));
|
||||
$userPhone = input("post.userPhone");
|
||||
$rs = array();
|
||||
if(!WSTIsPhone($userPhone)){
|
||||
exit(jsonReturn("手机号格式不正确!"));
|
||||
}
|
||||
if($this->user['userPhone'] && $this->user['userPhone'] == $userPhone){
|
||||
exit(jsonReturn("请输入实名认证的亲人手机号!"));
|
||||
}
|
||||
$m = Model('common/Users');
|
||||
$rs = $m->checkUserPhone($userPhone,0,'loginName');
|
||||
if($rs["status"]==1){
|
||||
exit(jsonReturn('手机号不存在'));
|
||||
}
|
||||
$rv['status'] = -1;
|
||||
$rv['msg'] = '发送失败';
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$tpl = WSTMsgTemplates('PHONE_USER_AUTH_FAMILY_VERFIY');
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['name'=>$rs['loginName'],'code'=>$phoneVerify]];
|
||||
$m = Model('common/LogSms');
|
||||
$rv = $m->sendSMS(0,$userPhone,$params,'PHONE_USER_AUTH_FAMILY_VERFIY',$phoneVerify);
|
||||
}
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
session('auth_UserPhone',$userPhone);
|
||||
session('authCode_UserPhone',$phoneVerify);
|
||||
session('auth_UserPhone_Time',time());
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 添加/编辑亲人认证信息
|
||||
*/
|
||||
public function setAuthFamilyPersonal(){
|
||||
if($this->user['authType'] == 2) exit(jsonReturn('没有权限!'));
|
||||
$data = input('post.');
|
||||
|
||||
$validate = \think\Loader::validate('Auth');
|
||||
if(!$validate->scene('family')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
|
||||
$id = isset($data['id']) ? $data['id'] : 0;
|
||||
if(!$id){
|
||||
$userPhone = session('auth_UserPhone');
|
||||
if(!$userPhone){
|
||||
exit(jsonReturn('操作超时,请重试!'));
|
||||
}
|
||||
$auth_ok = session('auth_ok');
|
||||
if(empty($auth_ok)) exit(jsonReturn('操作超时,请重新再试!'));
|
||||
|
||||
|
||||
$where['userPhone']=$userPhone;
|
||||
$userInfo = getUserInfo($where,'userId');
|
||||
if($userInfo){
|
||||
$data['familyId']=$userInfo['userId'];
|
||||
$am = new M();
|
||||
$familyInfo = $am->getInfo(['userId'=>$userInfo['userId'],'status'=>1],'householdName,householdIdCard');
|
||||
if(!$familyInfo){
|
||||
exit(jsonReturn('亲人认证账号必须为个人实名通过会员!'));
|
||||
}
|
||||
$data['familyName'] = $familyInfo['householdName'];
|
||||
$data['familyIdCard'] = $familyInfo['householdIdCard'];
|
||||
}else{
|
||||
exit(jsonReturn('未找到用户'));
|
||||
}
|
||||
}
|
||||
unset($data['id']);
|
||||
$userId = $this->getUserId();
|
||||
$data['userId'] = $userId;
|
||||
$m = new FM();
|
||||
$m->setTable('auth_family_personal');
|
||||
if(!$id && $m->getInfo(['familyId'=>$data['familyId'],'userId'=>$userId],'id')){
|
||||
exit(jsonReturn('此亲人已认证,请更换'));
|
||||
}
|
||||
if($id){//编辑
|
||||
$isSuccess = $m->updateInfo(['userId'=>$userId,'id'=>$id],$data);
|
||||
}else{//新增
|
||||
$isSuccess = $m->insertInfo($data);
|
||||
}
|
||||
|
||||
if(false !== $isSuccess){
|
||||
session('auth_UserPhone',null);
|
||||
session('auth_ok',null);
|
||||
exit(jsonReturn('提交成功',1));
|
||||
}else{
|
||||
exit(jsonReturn('操作失败,请重试'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取银行列表
|
||||
*/
|
||||
public function getBankNameList(){
|
||||
$bankList = Model('banks')->listQuery();
|
||||
exit(jsonReturn('',1,$bankList));
|
||||
}
|
||||
/**
|
||||
* 获取会员银行列表
|
||||
*/
|
||||
public function getCompanyBankList(){
|
||||
$bankList = Model('CompanyBank')->getSelect(['userId'=>$this->getUserId()],'*');
|
||||
exit(jsonReturn('',1,$bankList));
|
||||
}
|
||||
/**
|
||||
* 获取会员银行卡信息
|
||||
*/
|
||||
public function getCompanyBankInfo(){
|
||||
$id = (int)input('post.id/d');
|
||||
$bankInfo = Model('CompanyBank')->getInfo(['userId'=>$this->getUserId(),'id'=>$id],'id,bankName,accountName,bankNo');
|
||||
exit(jsonReturn('',1,$bankInfo));
|
||||
}
|
||||
/**
|
||||
* 删行会员银行卡
|
||||
*/
|
||||
public function delCompanyBank(){
|
||||
if($this->user['authType'] != 2) exit(jsonReturn('没有权限!'));
|
||||
$id = (int)input('post.id/d');
|
||||
$payPwd = input("post.payPwd");
|
||||
if(md5($payPwd) != $this->user['payPwd']){
|
||||
exit(jsonReturn('操作密码错误'));
|
||||
}
|
||||
$rs = Model('CompanyBank')->updateInfo(['userId'=>$this->getUserId(),'id'=>$id],['dataFlag'=>-1]);
|
||||
if(false !== $rs){
|
||||
exit(jsonReturn('删除成功',1));
|
||||
}
|
||||
exit(jsonReturn('删除失败,请重试'));
|
||||
}
|
||||
/**
|
||||
* 添加/编辑银行卡信息
|
||||
*/
|
||||
public function setBank(){
|
||||
if($this->user['authType'] != 2) exit(jsonReturn('合作认证账号才可以添加银行卡'));
|
||||
$m = Model('CompanyBank');
|
||||
$data = input('post.');
|
||||
$validate = \think\Loader::validate('Auth');
|
||||
if(!$validate->scene('bank')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
$id = isset($data['id']) ? $data['id'] : 0;
|
||||
$data['userId'] = $this->getUserId();
|
||||
if($id){//编辑
|
||||
$isSuccess = $m->updateInfo(['userId'=>$data['userId'],'id'=>$id],$data);
|
||||
}else{//新增
|
||||
$isSuccess = $m->insertInfo($data);
|
||||
}
|
||||
if(false !== $isSuccess){
|
||||
exit(jsonReturn('提交成功',1));
|
||||
}else{
|
||||
exit(jsonReturn('操作失败,请重试'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取合作人验证码
|
||||
*/
|
||||
public function getPartnerPhoneCode(){
|
||||
if(2 != $this->user['authType'])exit(jsonReturn('个人认证不可添加合作人'));
|
||||
$userPhone = input("post.userPhone");
|
||||
$rs = array();
|
||||
if(!WSTIsPhone($userPhone)){
|
||||
exit(jsonReturn("手机号格式不正确!"));
|
||||
}
|
||||
if($this->user['userPhone'] && $this->user['userPhone'] == $userPhone){
|
||||
exit(jsonReturn("请输入实名认证的手机号!"));
|
||||
}
|
||||
$m = Model('common/Users');
|
||||
$rs = $m->checkUserPhone($userPhone,0,'loginName');
|
||||
if($rs["status"]==1){
|
||||
exit(jsonReturn('手机号不存在'));
|
||||
}
|
||||
$rv['status'] = -1;
|
||||
$rv['msg'] = '发送失败';
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$tpl = WSTMsgTemplates('PHONE_USER_AUTH_PARTNER_VERFIY');
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['name'=>$rs['loginName'],'code'=>$phoneVerify]];
|
||||
$m = Model('common/LogSms');
|
||||
$rv = $m->sendSMS(0,$userPhone,$params,'PHONE_USER_AUTH_PARTNER_VERFIY',$phoneVerify);
|
||||
}
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
session('auth_UserPhone',$userPhone);
|
||||
session('authCode_UserPhone',$phoneVerify);
|
||||
session('auth_UserPhone_Time',time());
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 添加/编辑合伙人认证信息
|
||||
*/
|
||||
public function setAuthPartner(){
|
||||
if(2 != $this->user['authType'])exit(jsonReturn('个人认证不可添加合作人'));
|
||||
$data = input('post.');
|
||||
|
||||
$validate = \think\Loader::validate('Auth');
|
||||
if(!$validate->scene('partner')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
|
||||
$userId = $this->getUserId();
|
||||
if(isset($data['id'])){
|
||||
$m->setTable('auth_company_partner');
|
||||
$info = $m->getInfo(['id'=>$data['id'],'dataFlag'=>1],'userId,partnerId');
|
||||
if(!$info || $info['userId'] != $userId){
|
||||
exit(jsonReturn('没有权限!'));
|
||||
}
|
||||
$where['userId']=$info['partnerId'];
|
||||
$userInfo = getUserInfo($where,'userId,authType');
|
||||
}else{
|
||||
$userPhone = session('auth_UserPhone');
|
||||
if(!$userPhone){
|
||||
exit(jsonReturn('操作超时,请重试!'));
|
||||
}
|
||||
$auth_ok = session('auth_ok');
|
||||
if(empty($auth_ok)) exit(jsonReturn('操作超时,请重新再试!'));
|
||||
|
||||
$where['userPhone']=$userPhone;
|
||||
$userInfo = getUserInfo($where,'userId,authType');
|
||||
}
|
||||
|
||||
if($userInfo){
|
||||
$data['partnerId']=$userInfo['userId'];
|
||||
$am = new M();
|
||||
if(1 == $userInfo['authType']){
|
||||
$field = 'householdName uName,householdIdCard idCard';
|
||||
$uName = 'familyName';
|
||||
$idCard = 'familyIdCard';
|
||||
}elseif(2 == $userInfo['authType']){
|
||||
$am->setTable('auth_company');
|
||||
$field = 'trueName uName,idCard';
|
||||
$uName = 'uName';
|
||||
$idCard = 'idCard';
|
||||
}else{
|
||||
exit(jsonReturn('合作认证账号必须为实名通过会员'));
|
||||
}
|
||||
$authInfo = $am->getInfo(['userId'=>$userInfo['userId'],'status'=>1],$field);
|
||||
if(!$authInfo){
|
||||
exit(jsonReturn('合作认证账号必须为实名通过会员!'));
|
||||
}
|
||||
$data[$uName] = $authInfo['uName'];
|
||||
$data[$idCard] = $authInfo['idCard'];
|
||||
}else{
|
||||
exit(jsonReturn('未找到用户'));
|
||||
}
|
||||
$id = isset($data['id']) ? $data['id'] : 0;
|
||||
unset($data['id']);
|
||||
$data['userId'] = $userId;
|
||||
$m = new FM();
|
||||
$m->setTable('auth_company_partner');
|
||||
if(!$id && $m->getInfo(['partnerId'=>$data['partnerId'],'userId'=>$userId],'id')){
|
||||
exit(jsonReturn('此合作人已认证,请更换'));
|
||||
}
|
||||
if($id){//编辑
|
||||
$stakeSum = $m->getSum(['userId'=>$userId,'id'=>['<>',$id]],'stake');
|
||||
if(($stakeSum + $data['stake']) > 100){
|
||||
exit(jsonReturn('股份分配超出100%比例,当前最大修改比例'.(100-$stakeSum),1));
|
||||
}
|
||||
$isSuccess = $m->updateInfo(['userId'=>$userId,'id'=>$id],$data);
|
||||
}else{//新增
|
||||
$stakeSum = $m->getSum(['userId'=>$userId],'stake');
|
||||
if(($stakeSum + $data['stake']) > 100){
|
||||
exit(jsonReturn('股份分配超出100%比例,当前最大修改比例'.(100-$stakeSum),1));
|
||||
}
|
||||
$isSuccess = $m->insertInfo($data);
|
||||
}
|
||||
|
||||
if(false !== $isSuccess){
|
||||
session('auth_UserPhone',null);
|
||||
session('auth_ok',null);
|
||||
exit(jsonReturn('提交成功',1));
|
||||
}else{
|
||||
exit(jsonReturn('操作失败,请重试'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
112
hyhproject/app/controller/Base.php
Executable file
112
hyhproject/app/controller/Base.php
Executable file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use think\Controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 基础控制器
|
||||
*/
|
||||
class Base extends Controller {
|
||||
//token
|
||||
private $token = '';
|
||||
//用户 id
|
||||
private $userId = 0;
|
||||
|
||||
protected $user = [];
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
// 权限验证方法
|
||||
protected function checkDataAuth(){
|
||||
$shopId = (int)input('post.shopId');
|
||||
if(!$shopId ){
|
||||
exit(jsonReturn('参数传递不完整'));
|
||||
}
|
||||
$shopInfo = Model('shops')->getFieldsById($shopId,'shopId,userId');
|
||||
if(empty($shopInfo) || $shopInfo['userId'] != $this->getUserId()){
|
||||
exit(jsonReturn('没有权限!'.$this->getUserId()));
|
||||
}
|
||||
session('WST_USER.shopId',$shopId);
|
||||
}
|
||||
// 权限验证方法
|
||||
protected function checkAuth(){
|
||||
//正式上线要解开注释
|
||||
$user = session('WST_USER');
|
||||
if(empty($user)){
|
||||
if(!$this->checkToken()){
|
||||
die('{"status":-999,"msg":"您还未登录!"}');
|
||||
}
|
||||
}else{
|
||||
$this->user = $user;
|
||||
}
|
||||
//商家需要判断是否有优惠款未提交
|
||||
if($this->user['userType'] == 1 && strtolower(request()->controller()) != 'shoporders'){
|
||||
$rs = Model('common/Orders')->checkCertificate($this->getUserId());
|
||||
if(1 != $rs['status']){
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
}
|
||||
// if(0 == $this->user['userStatus']){
|
||||
// die('{"status":-1,"msg":"此账号已被禁用,请重新登录!"}');
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* token检查验证
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function checkToken(){
|
||||
$token = $this->request->header('HYH-Token');
|
||||
if (empty($token)) {
|
||||
return false;//未发送token
|
||||
}
|
||||
$this->token = $token;
|
||||
$user = getUserByToken($token);
|
||||
if (empty($user)) {
|
||||
return false;//登录已失效!
|
||||
}
|
||||
$this->user = $user;
|
||||
session('WST_USER',$user);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 获取会员ID
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getUserId(){
|
||||
return $this->user['userId'];
|
||||
}
|
||||
/**
|
||||
* 获取推荐ID
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getPid(){
|
||||
return Model('UserTrees')->getField($this->userId);
|
||||
}
|
||||
/**
|
||||
* 上传图片
|
||||
*/
|
||||
public function uploadPic(){
|
||||
return WSTUploadPic(0);
|
||||
}
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
public function getVerify(){
|
||||
WSTVerify();
|
||||
}
|
||||
//登录验证方法--商家
|
||||
protected function checkShopAuth(){
|
||||
// $user = session('WST_USER');
|
||||
// if(empty($user)){
|
||||
// if(!$this->checkToken()){
|
||||
// // die('{"status":-999,"msg":"您还未登录"}');
|
||||
// }
|
||||
if(empty($this->user['userType']) || $this->user['userType'] == 0) die('{"status":-2,"msg":"请先申请开店"}');
|
||||
// }else{
|
||||
// if($user['userType'] == 0) die('{"status":-2,"msg":"请先申请开店"}');
|
||||
// $this->user = $user;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
26
hyhproject/app/controller/Brands.php
Executable file
26
hyhproject/app/controller/Brands.php
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Brands as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 品牌控制器
|
||||
*/
|
||||
class Brands extends Base{
|
||||
/**
|
||||
* 主页
|
||||
*/
|
||||
public function index(){
|
||||
return $this->fetch('brands');
|
||||
}
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = new M();
|
||||
$rs = $m->pageQuery(input('pagesize/d'));
|
||||
foreach ($rs['Rows'] as $key =>$v){
|
||||
$rs['Rows'][$key]['brandImg'] = WSTImg($v['brandImg'],2);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
}
|
199
hyhproject/app/controller/Carts.php
Executable file
199
hyhproject/app/controller/Carts.php
Executable file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Carts as M;
|
||||
use wstmart\common\model\UserAddress;
|
||||
use wstmart\common\model\Payments;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 购物车控制器
|
||||
*/
|
||||
class Carts extends Base{
|
||||
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/**
|
||||
* 批量修改购物车状态
|
||||
*/
|
||||
public function batchChangeCartGoods(){
|
||||
$m = new M();
|
||||
$rs = $m->batchChangeCartGoods();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 查看购物车列表
|
||||
*/
|
||||
public function index(){
|
||||
$m = new M();
|
||||
$carts = $m->getCarts(false);
|
||||
exit(jsonReturn("",1,$carts));
|
||||
}
|
||||
/**
|
||||
* 加入购物车
|
||||
*/
|
||||
public function addCart(){
|
||||
$m = new M();
|
||||
$rs = $m->addCart();
|
||||
$rs['cartNum'] = WSTCartNum();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 修改购物车商品状态
|
||||
*/
|
||||
public function changeCartGoods(){
|
||||
$m = new M();
|
||||
$rs = $m->changeCartGoods();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 删除购物车里的商品
|
||||
*/
|
||||
public function delCart(){
|
||||
$m = new M();
|
||||
$rs= $m->delCart();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 计算运费、惠宝和总商品价格
|
||||
*/
|
||||
public function getCartMoney(){
|
||||
$m = new M();
|
||||
$data = $m->getCartMoney();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 计算运费、惠宝和总商品价格
|
||||
*/
|
||||
public function getMoney(){
|
||||
$type = (int)input('type');
|
||||
if($type == 1){
|
||||
$rs = model('carts')->getMoney();//立即下单获取价格
|
||||
}else{
|
||||
$m = new M();
|
||||
$rs =$m->getCartMoney();//购物车获取价格
|
||||
}
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 计算运费、惠宝和总商品价格/虚拟商品
|
||||
*/
|
||||
public function getQuickCartMoney(){
|
||||
$m = new M();
|
||||
$data = $m->getQuickCartMoney();
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 立即购买保存下参数
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function buy(){
|
||||
$rs = model('Carts')->buy();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 跳去购物车结算页面
|
||||
*/
|
||||
public function settlement(){
|
||||
|
||||
$m = new M();
|
||||
//获取一个用户地址
|
||||
$addressId = (int)input('addressId');
|
||||
$ua = new UserAddress();
|
||||
if($addressId>0){
|
||||
$userAddress = $ua->getById($addressId);
|
||||
}else{
|
||||
$userAddress = $ua->getDefaultAddress();
|
||||
}
|
||||
//$this->assign('userAddress',$userAddress);
|
||||
//获取支付方式
|
||||
$pa = new Payments();
|
||||
$payments = $pa->getByGroup('4',-1,true);//具体支付场景1pc,2wap,3微信,4app
|
||||
|
||||
//dump($payments);
|
||||
//获取已选的购物车商品
|
||||
//$carts = $m->getCarts(true, 0, $userAddress);// 添加运费显示 mark hsf 20171116
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$areaId2 = isset($userAddress['areaId2']) ? $userAddress['areaId2'] : 0;
|
||||
|
||||
$type = (int)input('type');
|
||||
if($type == 1){
|
||||
$carts = model('carts')->buyNow($areaId2);//立即下单结算方式
|
||||
}else{
|
||||
$carts = $m->getCarts(true, 0, $areaId2);
|
||||
}
|
||||
if(empty($carts['carts'])){
|
||||
exit(jsonReturn('未找到相关商品',-1));
|
||||
}
|
||||
// //$carts = $m->getCarts(true, 0, $userAddress);购物车结算方式
|
||||
hook("appControllerCartsSettlement",["carts"=>$carts,"payments"=>&$payments]);
|
||||
// //ect整合相关优惠还有判断不能和在线支付商品一块
|
||||
// hook("ectIntegration",["carts"=>&$carts,'isSettlement'=>true,'uId'=>(int)session('WST_USER.userId')]);
|
||||
//
|
||||
// //获取用户惠宝
|
||||
$user = model('users')->getFieldsById($userId,'userScore,loginName,userMoney,userECT');
|
||||
// //计算可用惠宝和金额
|
||||
// $goodsTotalMoney = round((($carts['goodsTotalMoney'] - $carts['promotionMoney'] - $carts['allShippingMoney']) * HuiScale()),2);//$carts['goodsTotalMoney']; 惠宝最多可抵用20% mark 20170907
|
||||
// $goodsTotalScore = WSTScoreToMoney($goodsTotalMoney,true);
|
||||
// $useOrderScore =0;
|
||||
// $useOrderMoney = 0;
|
||||
// // if(!isset($carts['ect_pay']) || !$carts['ect_pay']){
|
||||
// if($user['userScore']>$goodsTotalScore){//个人所有积分大于订单可抵用的积分
|
||||
// $useOrderScore = $goodsTotalScore;//可抵下的积分
|
||||
// $useOrderMoney = $goodsTotalMoney;//可抵下的金额
|
||||
// }else{
|
||||
// $useOrderScore = $user['userScore'];//可抵下的积分为自已所有的积分
|
||||
// $useOrderMoney = WSTScoreToMoney($useOrderScore);//转换成金额
|
||||
// }
|
||||
// // }
|
||||
$data = $carts;
|
||||
$data['loginName'] = $user['loginName'];
|
||||
$data['userMoney'] = $user['userMoney'];
|
||||
$data['userECT'] = $user['userECT'];
|
||||
$data['userAddress'] = $userAddress;
|
||||
$data['payments'] = $payments;
|
||||
$data['useOrderScore'] = 0;// $useOrderScore;//可抵积分
|
||||
$data['useOrderMoney'] = 0;//$useOrderMoney;//可抵积分换算成金额
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
/**
|
||||
* 跳去虚拟商品购物车结算页面
|
||||
*/
|
||||
public function quickSettlement(){
|
||||
$m = new M();
|
||||
//获取支付方式
|
||||
$pa = new Payments();
|
||||
$payments = $pa->getByGroup('2');
|
||||
$this->assign('payments',$payments);
|
||||
//获取用户惠宝
|
||||
$user = model('users')->getFieldsById((int)session('WST_USER.userId'),'userScore');
|
||||
//获取已选的购物车商品
|
||||
$carts = $m->getQuickCarts();
|
||||
//计算可用惠宝和金额
|
||||
$goodsTotalMoney = $carts['goodsTotalMoney'];
|
||||
$goodsTotalScore = WSTScoreToMoney($goodsTotalMoney,true);
|
||||
$useOrderScore =0;
|
||||
$useOrderMoney = 0;
|
||||
if($user['userScore']>$goodsTotalScore){
|
||||
$useOrderScore = $goodsTotalScore;
|
||||
$useOrderMoney = $goodsTotalMoney;
|
||||
}else{
|
||||
$useOrderScore = $user['userScore'];
|
||||
$useOrderMoney = WSTScoreToMoney($useOrderScore);
|
||||
}
|
||||
$this->assign('userOrderScore',$useOrderScore);
|
||||
$this->assign('userOrderMoney',$useOrderMoney);
|
||||
|
||||
$this->assign('carts',$carts);
|
||||
return $this->fetch('settlement_quick');
|
||||
}
|
||||
|
||||
/**
|
||||
* APP购物车推荐商品
|
||||
*/
|
||||
public function recommendGoods(){
|
||||
$m = new M();
|
||||
$recommendGoods = $m->recommendGoods();
|
||||
exit(json_encode($recommendGoods));
|
||||
}
|
||||
}
|
54
hyhproject/app/controller/Cashconfigs.php
Executable file
54
hyhproject/app/controller/Cashconfigs.php
Executable file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 提现账号控制器
|
||||
*/
|
||||
class Cashconfigs extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth',
|
||||
];
|
||||
/**
|
||||
* 查看提现账号
|
||||
*/
|
||||
public function index(){
|
||||
$this->assign('area',model('areas')->listQuery(0));
|
||||
$this->assign('banks',model('banks')->listQuery(0));
|
||||
return $this->fetch('users/cashconfigs/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户数据
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$data = model('CashConfigs')->pageQuery(0,$userId);
|
||||
return jsonReturn("", 1,$data);
|
||||
}
|
||||
/**
|
||||
* 获取记录
|
||||
*/
|
||||
public function getById(){
|
||||
$id = (int)input('id');
|
||||
return model('CashConfigs')->getById($id);
|
||||
}
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public function add(){
|
||||
return model('CashConfigs')->add();
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit(){
|
||||
return model('CashConfigs')->edit();
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del(){
|
||||
return model('CashConfigs')->del();
|
||||
}
|
||||
}
|
34
hyhproject/app/controller/Cashdraws.php
Executable file
34
hyhproject/app/controller/Cashdraws.php
Executable file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 提现记录控制器
|
||||
*/
|
||||
class Cashdraws extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth',
|
||||
];
|
||||
/**
|
||||
* 查看用户提现记录
|
||||
*/
|
||||
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 jsonReturn("", 1,$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现
|
||||
*/
|
||||
public function drawMoney(){
|
||||
return model('CashDraws')->drawMoney();
|
||||
}
|
||||
}
|
34
hyhproject/app/controller/Chain3.php
Executable file
34
hyhproject/app/controller/Chain3.php
Executable file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Chain3 extends Chain3base{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->wei = 8;
|
||||
}
|
||||
/**
|
||||
*查询ect余额
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function get_Balance(){
|
||||
$address = $this->getCoinbase();//trim(input('post.address'));
|
||||
$this->web3->eth->getBalance($address , function ($err, $balance) {
|
||||
if ($err !== null) {
|
||||
exit(jsonReturn($err->getMessage()));
|
||||
// echo 'Error: ' . $err->getMessage();
|
||||
//return;
|
||||
}else{
|
||||
$my_balance = $balance->toString();
|
||||
$my_balance = $my_balance/pow(10,$this->wei);
|
||||
$data['balance'] = $my_balance;
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
117
hyhproject/app/controller/Chain3base.php
Executable file
117
hyhproject/app/controller/Chain3base.php
Executable file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use think\Controller;
|
||||
Vendor('web3.vendor.autoload');
|
||||
use Web3\Web3;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Chain3base extends Controller{
|
||||
/**
|
||||
* web3
|
||||
*
|
||||
* @var \Web3\Web3
|
||||
*/
|
||||
protected $web3;
|
||||
|
||||
protected $wei = 18;
|
||||
/**
|
||||
* testRinkebyHost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $testRinkebyHost = 'http://localhost';
|
||||
|
||||
/**
|
||||
* testHost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $testHost = 'http://localhost:8545';
|
||||
|
||||
/**
|
||||
* coinbase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $coinbase;
|
||||
|
||||
public function __construct(){
|
||||
$web3 = new Web3($this->testHost);
|
||||
$this->web3 = $web3;
|
||||
}
|
||||
public function getCoinbase(){
|
||||
$this->web3->eth->coinbase(function ($err, $coinbase) {
|
||||
if ($err !== null) {
|
||||
$this->coinbase = 0;
|
||||
//return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->coinbase = $coinbase;
|
||||
});
|
||||
return $this->coinbase;
|
||||
|
||||
////获取本机账号列表
|
||||
// $this->web3->eth->accounts(function ($err, $accounts) use ($eth) {
|
||||
// if ($err !== null) {
|
||||
// echo 'Error: ' . $err->getMessage();
|
||||
// return;
|
||||
// }
|
||||
// dump($accounts);
|
||||
// });
|
||||
}
|
||||
/**
|
||||
*创建账号
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function create_account(){
|
||||
$pass = trim(input('post.pass'));
|
||||
if(strlen($pass) < 6 ){
|
||||
exit(jsonReturn('密码最低6位'));
|
||||
}
|
||||
$web3->personal->newAccount($pass, function ($err, $account) use (&$newAccount) {
|
||||
if ($err !== null) {
|
||||
exit(jsonReturn($err->getMessage()));
|
||||
// echo 'Error: ' . $err->getMessage();
|
||||
//return;
|
||||
}else{
|
||||
$data['account'] = $account;
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
});
|
||||
}
|
||||
protected function get_Balance(){
|
||||
$address = trim(input('post.address'));
|
||||
$this->web3->eth->getBalance($address , function ($err, $balance) {
|
||||
if ($err !== null) {
|
||||
exit(jsonReturn($err->getMessage()));
|
||||
// echo 'Error: ' . $err->getMessage();
|
||||
//return;
|
||||
}else{
|
||||
$my_balance = $balance->toString();
|
||||
$my_balance = $my_balance/pow(10,$this->wei);
|
||||
$data['balance'] = $my_balance;
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
});
|
||||
}
|
||||
//账号解锁
|
||||
protected function unlock_account($pass,$address){
|
||||
$web3->personal->unlockAccount($address, $pass, function ($err, $unlocked) {
|
||||
if ($err !== null) {
|
||||
exit(jsonReturn($err->getMessage()));
|
||||
// echo 'Error: ' . $err->getMessage();
|
||||
// return;
|
||||
}
|
||||
if($unlocked) {
|
||||
$data['unlock'] = 1;//$unlocked;
|
||||
exit(jsonReturn('',1,$data));
|
||||
} else {
|
||||
$data['unlock'] = 0;
|
||||
exit(jsonReturn('',1,$data));
|
||||
//echo 'New account isn\'t unlocked' . PHP_EOL;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
148
hyhproject/app/controller/Ect.php
Executable file
148
hyhproject/app/controller/Ect.php
Executable file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Orders as OM;
|
||||
use wstmart\app\model\EctElevenPay as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Ect extends Base{
|
||||
|
||||
/**
|
||||
* 跳去支付页面
|
||||
*/
|
||||
public function payment(){
|
||||
$data = [];
|
||||
$data['orderNo'] = input('orderNo');
|
||||
$data['isBatch'] = (int)input('isBatch');
|
||||
$data['userId'] = (int)session('WST_USER.userId');
|
||||
|
||||
$m = new OM();
|
||||
$rs = $m->getOrderPayInfo($data);//获取订单金额以及用户钱包金额
|
||||
|
||||
$pay['list'] = $m->getByUnique();// 根据订单唯一流水获取订单信息
|
||||
|
||||
if(empty($rs)){//已支付或者找不到此订单
|
||||
exit(jsonReturn('读取失败',-1));
|
||||
}else{
|
||||
$pay['needPay'] = $rs['needPay'];//需付款
|
||||
//获取用户钱包
|
||||
$user = model('users')->getFieldsById($data['userId'],'userECT,payPwd');
|
||||
$pay['userECT'] = $user['userECT'];
|
||||
$payPwd = $user['payPwd'];
|
||||
$payPwd = empty($payPwd)?0:1;
|
||||
$pay['payPwd'] = $payPwd;//1有密码0没设置密码
|
||||
}
|
||||
exit(jsonReturn('',1,$pay));
|
||||
|
||||
}
|
||||
private function getHTTPS($url) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
public function getDollerPrice(){
|
||||
$now_doller = db('doller')->where('id=1')->cache(true)->value('doller');
|
||||
exit(jsonReturn('',1,['now_doller'=>$now_doller]));
|
||||
}
|
||||
public function getToEctNum(){
|
||||
try{
|
||||
$url ='https://api.tokencan.net/exchange-open-api/open/api/get_ticker?symbol=ectusdt';
|
||||
$t_info = $this->getHTTPS($url);
|
||||
$t_info = json_decode($t_info);
|
||||
if(is_object($t_info)){
|
||||
$total_money = input('total_money');
|
||||
$t_usdt_price = $t_info->data->last;
|
||||
$now_doller = db('doller')->where('id=1')->value('doller');
|
||||
$now_rmb = round($t_usdt_price*$now_doller,2);
|
||||
$to_ect_num = round($total_money/$now_rmb,2);
|
||||
$ect_discount = Model('payments')->getPaymentDiscount('ect');
|
||||
$ect_msg='';
|
||||
if($ect_discount >= 0.9 && $ect_discount <1){
|
||||
$ect_msg=',ECT支付'.($ect_discount*10).'折';
|
||||
$to_ect_num *= $ect_discount;
|
||||
}
|
||||
$msg='当前ECT价格:'.$now_rmb.',订单价格:'.$total_money.$ect_msg.',共需:'.round($to_ect_num,2).' ECT';
|
||||
session('ect_rmb_price',$now_rmb);
|
||||
exit(jsonReturn($msg,1,['ect_num'=>$to_ect_num]));
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
exit(jsonReturn('获取价格失败!',-1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取双11优惠券所需的ect数量和价格
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getEctNum(){
|
||||
$m = new M();
|
||||
$result = $m->getEctNum();
|
||||
exit(json_decode($result));
|
||||
}
|
||||
/**
|
||||
* 支付双十一优惠券的ect价格
|
||||
*/
|
||||
public function payElevenEct(){
|
||||
$m = new M();
|
||||
$result = $m->payElevenEct();
|
||||
exit(json_decode($result));
|
||||
}
|
||||
/**
|
||||
* 当前用户的ECT数量
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function userECT(){
|
||||
$data['ectNum'] = model('Ectwallet')->getEctNum();
|
||||
// $data['eAddressInfo'] = model('Ectwallet')->getDefaultAddress();
|
||||
// return WSTReturn('',1,$data);
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ECT支付
|
||||
*/
|
||||
public function payByEct(){
|
||||
$m = new OM();
|
||||
exit(json_encode($m->payByEct()));
|
||||
}
|
||||
///**
|
||||
// *查询ect余额
|
||||
// *
|
||||
// * @return void
|
||||
// */
|
||||
// public function get_balance(){
|
||||
// $ect_model = Model('Ect');
|
||||
// $address = $ect_model->getCoinbase();//trim(input('post.address'));
|
||||
// if(strlen($address)<=40){
|
||||
// exit(jsonReturn('地址不正确'));
|
||||
// }
|
||||
// dump($ect_model->getBalance($address));
|
||||
// }
|
||||
// public function get_mc_Balance(){
|
||||
// $address = $this->getCoinbase();//trim(input('post.address'));
|
||||
// $this->web3->eth->getBalance($address , function ($err, $balance) {
|
||||
// if ($err !== null) {
|
||||
// exit(jsonReturn($err->getMessage()));
|
||||
// // echo 'Error: ' . $err->getMessage();
|
||||
// //return;
|
||||
// }else{
|
||||
// $my_balance = $balance->toString();
|
||||
// $my_balance = $my_balance/pow(10,$this->wei);
|
||||
// $data['balance'] = $my_balance;
|
||||
// exit(jsonReturn('',1,$data));
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
232
hyhproject/app/controller/Ectwallets.php
Executable file
232
hyhproject/app/controller/Ectwallets.php
Executable file
@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace wstmart\app\controller;
|
||||
|
||||
use wstmart\common\model\Ectwallet;
|
||||
|
||||
/**
|
||||
|
||||
* ============================================================================
|
||||
|
||||
* 用户电子钱包控制器
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class Ectwallets extends Base{
|
||||
|
||||
|
||||
|
||||
protected $beforeActionList = ['checkAuth'];// 访问这些except下的方法不需要执行前置操作
|
||||
|
||||
/**
|
||||
|
||||
* 设置为默认地址
|
||||
|
||||
*/
|
||||
|
||||
public function setDefault(){
|
||||
|
||||
$rs = model('Ectwallet')->setDefault();
|
||||
|
||||
exit(json_encode($rs));
|
||||
|
||||
// return $rs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* [index description]
|
||||
|
||||
* @return [type] [description]
|
||||
|
||||
*/
|
||||
|
||||
public function index(){
|
||||
|
||||
$data['ectNum'] = model('Ectwallet')->getEctNum();
|
||||
|
||||
$data['eAddressInfo'] = model('Ectwallet')->getDefaultAddress();
|
||||
|
||||
// return WSTReturn('',1,$data);
|
||||
|
||||
exit(jsonReturn('',1,$data));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* [listQuery 钱包地址列表页]
|
||||
|
||||
* @return [type] [description]
|
||||
|
||||
*/
|
||||
|
||||
public function listQuery(){
|
||||
|
||||
$data = model('Ectwallet')->listQuery();
|
||||
|
||||
exit(jsonReturn('',1,$data));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 跳去修改地址
|
||||
|
||||
*/
|
||||
|
||||
public function edit(){
|
||||
|
||||
$id = input('post.eWalletId/d');
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$data = $m->infoById($id);
|
||||
|
||||
// return WSTReturn('',1,$data);
|
||||
|
||||
exit(jsonReturn('',1,$data));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 新增
|
||||
|
||||
*/
|
||||
|
||||
public function add(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->add();
|
||||
|
||||
exit(json_encode($rs));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 修改
|
||||
|
||||
*/
|
||||
|
||||
public function toEdit(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->edit();
|
||||
|
||||
exit(json_encode($rs));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 删除
|
||||
|
||||
*/
|
||||
|
||||
public function del(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->del();
|
||||
|
||||
exit(json_encode($rs));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 获取ect变更记录
|
||||
|
||||
*/
|
||||
|
||||
public function getEctLog(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->getEctLog();
|
||||
|
||||
exit(jsonReturn('',1,$rs));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 获取ect充值记录
|
||||
|
||||
*/
|
||||
|
||||
public function getEctRechargeLog(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->getEctRechargeLog();
|
||||
|
||||
exit(jsonReturn('',1,$rs));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 获取ect提现记录
|
||||
|
||||
*/
|
||||
|
||||
public function getUserEctCashLog(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->getUserEctCashLog();
|
||||
|
||||
exit(jsonReturn('',1,$rs));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 获取ect地址
|
||||
|
||||
*/
|
||||
|
||||
public function getEctAddress(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->getEctAddress();
|
||||
|
||||
exit(json_encode($rs));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* [withdraw 提现]
|
||||
|
||||
* @return [type] [description]
|
||||
|
||||
*/
|
||||
|
||||
public function withdraw(){
|
||||
|
||||
$m = model('Ectwallet');
|
||||
|
||||
$rs = $m->withdraw();
|
||||
|
||||
exit(json_encode($rs));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
21
hyhproject/app/controller/Error.php
Executable file
21
hyhproject/app/controller/Error.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 错误处理控制器
|
||||
*/
|
||||
class Error extends Base{
|
||||
public function index(){
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
return $this->fetch('error_sys');
|
||||
}
|
||||
public function message(){
|
||||
$code = input('code');
|
||||
if($code !== null && session($code)!=''){
|
||||
$this->assign('message',session($code));
|
||||
}else{
|
||||
$this->assign('message','操作错误,请联系商城管理员');
|
||||
}
|
||||
return $this->fetch('error_lost');
|
||||
}
|
||||
}
|
68
hyhproject/app/controller/Favorites.php
Executable file
68
hyhproject/app/controller/Favorites.php
Executable file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace wstmart\app\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();
|
||||
foreach($data['Rows'] as $k=>$v){
|
||||
$data['Rows'][$k]['goodsImg'] = WSTImg($v['goodsImg'],3);
|
||||
}
|
||||
exit(jsonReturn("", 1,$data));
|
||||
}
|
||||
/**
|
||||
* 关注的店铺列表
|
||||
*/
|
||||
public function listShopQuery(){
|
||||
$m = new M();
|
||||
$data = $m->listShopQuery();
|
||||
foreach($data['Rows'] as $k=>$v){
|
||||
$data['Rows'][$k]['shopImg'] = WSTImg($v['shopImg'],3);
|
||||
if(!empty($v['goods'])){
|
||||
foreach($v['goods'] as $k1=>$v1){
|
||||
$v[$k1]['goodsImg'] = WSTImg($v1['goodsImg'],3);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(jsonReturn("", 1,$data));
|
||||
}
|
||||
/**
|
||||
* 取消关注
|
||||
*/
|
||||
public function cancel(){
|
||||
$m = new M();
|
||||
$rs = $m->del();
|
||||
exit(jsonReturn("", 1,$rs));
|
||||
}
|
||||
/**
|
||||
* 增加关注
|
||||
*/
|
||||
public function add(){
|
||||
$m = new M();
|
||||
$rs = $m->add();
|
||||
exit(jsonReturn("", 1,$rs));
|
||||
}
|
||||
}
|
213
hyhproject/app/controller/Goods.php
Executable file
213
hyhproject/app/controller/Goods.php
Executable file
@ -0,0 +1,213 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\GoodsCats;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品控制器
|
||||
*/
|
||||
class Goods extends Base{
|
||||
protected $beforeActionList = [
|
||||
'checkAuth' => ['only'=>'history']
|
||||
];
|
||||
public function tmp(){
|
||||
return;
|
||||
$orderNo = [100066190,100066186,100065840,100065770,100065490,100065420,100065405,100065276,100064963,100064930,100064926,100064915,100064510,100064322,100064274,100064226,100064215,100064090,100064053,100063762,100063655,100063493,100063482,100063471,100063460,100063375,100063224,100063106,100063095,100063084,100063062,100063040,100063036,100063025,100063014,100063003,100062992,100062815,100066422,100066411,100066396,100066245];
|
||||
foreach ($orderNo as &$key) {
|
||||
echo $key;
|
||||
dump(model('OrderRefunds')->byRefund($key));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 商品主页
|
||||
*/
|
||||
public function detail(){
|
||||
|
||||
$m = model('goods');
|
||||
//获取商品id mark 20180323
|
||||
$goods_id = input('goodsId/d');
|
||||
$goods = $m->getBySale($goods_id);
|
||||
hook('mobileControllerGoodsIndex',['getParams'=>input()]);
|
||||
// 找不到商品记录
|
||||
if(empty($goods)) exit(jsonReturn("此商品已下架或被删除!".$goods_id, -22));
|
||||
//记录用户浏览商品
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
if($userId){
|
||||
$data['userId']= $userId;
|
||||
$data['goodsId']=$goods['goodsId'];
|
||||
$data['path']='3';
|
||||
$data['create_time']=time();
|
||||
$result=db('page_view')->insert($data);
|
||||
}
|
||||
$goods['goodsDesc']=htmlspecialchars_decode($goods['goodsDesc']);
|
||||
$rule = '/<img src="\/(upload.*?)"/';
|
||||
preg_match_all($rule, $goods['goodsDesc'], $images);
|
||||
|
||||
foreach($images[0] as $k=>$v){
|
||||
$goods['goodsDesc'] = str_replace('/'.$images[1][$k], '__ROOT__/'.WSTConf("CONF.goodsLogo") . "\" data-echo=\"__ROOT__/".WSTImg($images[1][$k],0), $goods['goodsDesc']);
|
||||
}
|
||||
if(!empty($goods)){
|
||||
// $history = cookie("wx_history_goods");
|
||||
// $history = is_array($history)?$history:[];
|
||||
// array_unshift($history, (string)$goods['goodsId']);
|
||||
// $history = array_values(array_unique($history));
|
||||
// if(!empty($history)){
|
||||
// cookie("wx_history_goods",$history,25920000);
|
||||
// }
|
||||
|
||||
$goods['imgcount'] = count($goods['gallery']);
|
||||
//$goods['imgwidth'] = 'width:'.$goods['imgcount'].'00%';
|
||||
}
|
||||
//添加注册推荐人 mark 20180323
|
||||
$goods['goods_url'] = url('mgoods-'.$goods_id.'.html','pName='.session('WST_USER.loginName'),'',true);
|
||||
$goods['goodsCount'] = $m->getGoodsCount($goods['shopId']);//全部商品数
|
||||
$goods['shopAccreds'] = model('shops')->shopAccreds($goods['shopId']);//店铺认证
|
||||
$goods['newGoodsCount'] = $m->getNewGoodsCount($goods['shopId']);//上新数
|
||||
$goods['favoritesShopsNum'] = model('favorites')->getFavoritesShopsNum($goods['shopId']);//关注数
|
||||
$goods['isFavorites'] = 0;//未关注该商品
|
||||
if($userId){
|
||||
$isFavorites = model('favorites')->isGetFavorites($goods['goodsId'],$userId);
|
||||
if($isFavorites){
|
||||
$goods['isFavorites'] = 1;//已关注该商品
|
||||
}
|
||||
}
|
||||
$couponList = $this->getCouponList(0);
|
||||
if(isset($couponList['data'])){
|
||||
$goods['couponList'] = $couponList['data'];//优惠券列表
|
||||
}else{
|
||||
$goods['couponList'] = [];//优惠券列表
|
||||
}
|
||||
|
||||
$goods['promotionList'] = $this->getPromotionList($goods['shopId'], $goods['goodsId'],0);//获取可用的满减活动
|
||||
$goods['oneAppraises'] = model('goods_appraises')->getOneAppraises($goods['goodsId']);//获取一个评论
|
||||
|
||||
$goods['showWhsle'] = 0;//是否显示批发价
|
||||
// $hyhlm_id = session('WST_USER.hyhlm_id');//联盟ID
|
||||
// if($hyhlm_id){
|
||||
// $lm_info = getLMUserByID($hyhlm_id,'u_level');
|
||||
// if($lm_info['u_level'] >= 1){
|
||||
// $goods['showWhsle'] = 1;
|
||||
// }
|
||||
// }
|
||||
// hook('afterGetGoods',['params'=>&$goods]);
|
||||
|
||||
//dump($goods);die;
|
||||
//exit(json_encode($goods));
|
||||
// dump(hook('mobileDocumentGoodsPropDetail'));
|
||||
// dump(hook('mobileDocumentGoodsPromotionDetail',['goods'=>$goods]));
|
||||
//die;
|
||||
$rsv = jsonReturn('', 1,$goods);
|
||||
|
||||
exit($rsv);
|
||||
}
|
||||
function gbk_to_utf8($data) {
|
||||
if( is_array($data) ) {
|
||||
foreach ($data as $k => $v) {
|
||||
if ( is_array($v) ) {
|
||||
$data[$k] = $this->gbk_to_utf8($v);
|
||||
} else {
|
||||
$data[$k] = iconv('GBK', 'UTF-8//IGNORE', $v);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
} else {
|
||||
$data = iconv('GBK', 'UTF-8//IGNORE', $data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取优惠券列表
|
||||
* @param integer $returnJson [是否返回json数据]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getCouponList($returnJson = 1){
|
||||
return;
|
||||
$m = new \addons\coupon\model\Coupons();
|
||||
$data = $m->getCouponsByGoods();
|
||||
if($returnJson == 1){
|
||||
exit(json_encode($data));
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取满就送列表
|
||||
* @param [type] $shopId [商铺ID]
|
||||
* @param [type] $goodsId [商品ID]
|
||||
* @param integer $returnJson [是否返回json数据]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getPromotionList($shopId=0,$goodsId=0,$returnJson = 1){
|
||||
return;
|
||||
$shopId = ($shopId==0)?(int)input('shopId'):$shopId;
|
||||
$goodsId = ($goodsId==0)?(int)input('goodsId'):$goodsId;
|
||||
$rm = new \addons\reward\model\Rewards();
|
||||
$data = $rm->getAvailableRewards($shopId, $goodsId);
|
||||
if($returnJson == 1){
|
||||
exit(json_encode("",1,$data));
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
public function lists(){
|
||||
$this->assign("keyword", input('keyword'));
|
||||
$this->assign("catId", input('catId/d'));
|
||||
$this->assign("brandId", input('brandId/d'));
|
||||
return $this->fetch('goods_list');
|
||||
}
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = model('goods');
|
||||
$gc = new GoodsCats();
|
||||
$catId = (int)input('catId');
|
||||
if($catId>0){
|
||||
$goodsCatIds = $gc->getParentIs($catId);
|
||||
}else{
|
||||
$goodsCatIds = [];
|
||||
}
|
||||
$from = (int)input("from", 0);
|
||||
$scale = 0;
|
||||
switch ($from){
|
||||
case 1:
|
||||
$scale = dataConf('discountRateGtToShopping');
|
||||
break;
|
||||
case 2:
|
||||
$scale = dataConf('discountRateGtToHelp');
|
||||
break;
|
||||
case 3:
|
||||
$scale = dataConf('discountRateGtToHelpShopping');
|
||||
break;
|
||||
}
|
||||
$_where['discountRate'] = [">=", $scale];
|
||||
$rs = $m->pageQuery($goodsCatIds, $_where);
|
||||
foreach ($rs['Rows'] as $key =>$v){
|
||||
$rs['Rows'][$key]['goodsImg'] = WSTImg($v['goodsImg'],2);
|
||||
}
|
||||
// `券`标签
|
||||
hook('afterQueryGoods',['page'=>&$rs]);
|
||||
exit(jsonReturn("", 1,$rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览历史页面
|
||||
*/
|
||||
public function history(){
|
||||
return $this->fetch('users/history/list');
|
||||
}
|
||||
/**
|
||||
* 获取浏览历史
|
||||
*/
|
||||
public function historyQuery(){
|
||||
$rs = model('goods')->historyQuery();
|
||||
if(!empty($rs)){
|
||||
foreach($rs['Rows'] as $k=>$v){
|
||||
$rs['Rows'][$k]['goodsImg'] = WSTImg($v['goodsImg'],3);
|
||||
}
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
}
|
44
hyhproject/app/controller/Goodsappraises.php
Executable file
44
hyhproject/app/controller/Goodsappraises.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\GoodsAppraises as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 评价控制器
|
||||
*/
|
||||
class GoodsAppraises extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth' => ['except'=>'getbyid'],// 只要访问only下的方法才才需要执行前置操作
|
||||
];
|
||||
/**
|
||||
* 根据商品id评论
|
||||
*/
|
||||
public function getById(){
|
||||
$m = new M();
|
||||
$rs = $m->getById();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 根据订单id,用户id,商品id获取评价
|
||||
*/
|
||||
public function getAppr(){
|
||||
$m = model('GoodsAppraises');
|
||||
$rs = $m->getAppr();
|
||||
if(!empty($rs['data']['images'])){
|
||||
$imgs = explode(',',$rs['data']['images']);
|
||||
foreach($imgs as $k=>$v){
|
||||
$imgs[$k] = WSTImg($v,1);
|
||||
}
|
||||
$rs['data']['images'] = $imgs;
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 添加评价
|
||||
*/
|
||||
public function add(){
|
||||
$m = new M();
|
||||
$rs = $m->add();
|
||||
return $rs;
|
||||
}
|
||||
}
|
32
hyhproject/app/controller/Goodscats.php
Executable file
32
hyhproject/app/controller/Goodscats.php
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\GoodsCats as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品分类控制器
|
||||
*/
|
||||
class GoodsCats extends Base{
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function index(){
|
||||
$m = new M();
|
||||
$goodsCatList = $m->getGoodsCats();
|
||||
exit(jsonReturn('',1,$goodsCatList));
|
||||
}
|
||||
public function getGoodsCat(){
|
||||
$m = new M();
|
||||
$goodsCatList = $m->getGoodsCat();
|
||||
exit(jsonReturn('',1,$goodsCatList));
|
||||
}
|
||||
/**
|
||||
* 获取分类名
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getCatName(){
|
||||
$m = new M();
|
||||
$rs = $m->getCatName();
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
|
||||
}
|
35
hyhproject/app/controller/Goodsconsult.php
Executable file
35
hyhproject/app/controller/Goodsconsult.php
Executable file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\GoodsConsult as CG;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品咨询控制器
|
||||
*/
|
||||
class GoodsConsult extends Base{
|
||||
/**
|
||||
* 商品咨询页
|
||||
*/
|
||||
public function index(){
|
||||
$this->assign('goodsId',(int)input('goodsId'));
|
||||
return $this->fetch('goodsconsult/list');
|
||||
}
|
||||
/**
|
||||
* 根据商品id获取商品咨询
|
||||
*/
|
||||
public function listQuery(){
|
||||
$m = new CG();
|
||||
return $m->listQuery();
|
||||
}
|
||||
/**
|
||||
* 发布商品咨询页
|
||||
*/
|
||||
public function consult(){
|
||||
$this->assign('goodsId',(int)input('goodsId'));
|
||||
return $this->fetch('goodsconsult/consult');
|
||||
}
|
||||
public function add(){
|
||||
$m = new CG();
|
||||
return $m->add();
|
||||
}
|
||||
|
||||
}
|
122
hyhproject/app/controller/Index.php
Executable file
122
hyhproject/app/controller/Index.php
Executable file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Index as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Index extends Base{
|
||||
public function tmp(){
|
||||
//$orderId = 80;
|
||||
// model('common/Settlements')->speedySettlement($orderId);
|
||||
// dump(input('post.'));
|
||||
//dump(Model('orders')->receive(56,1));
|
||||
}
|
||||
/**
|
||||
* 分配券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function startGiveVouchers(){
|
||||
Model('UserVouchers')->startGiveVouchers();
|
||||
}
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public function index(){
|
||||
echo 'hello';die;
|
||||
echo request()->ip();die;
|
||||
$m = new M();
|
||||
hook('mobileControllerIndexIndex',['getParams'=>input()]);
|
||||
|
||||
//秒杀商品
|
||||
// $now_time = time(); //当前时间
|
||||
// if(is_int($now_time/7200)){ //双整点时间,如:10:00, 12:00
|
||||
// $start_time = $now_time;
|
||||
// }else{
|
||||
// $start_time = floor($now_time/7200)*7200; //取得前一个双整点时间
|
||||
// }
|
||||
// $end_time = $start_time+7200; //结束时间
|
||||
|
||||
$year = date("Y");
|
||||
$month = date("m");
|
||||
$day = date("d");
|
||||
$start_time = mktime(8,0,0,$month,$day,$year);//当天开始时间戳
|
||||
$end_time= mktime(20,0,0,$month,$day,$year);//当天结束时间戳
|
||||
$this->assign('start_time',$start_time);
|
||||
$this->assign('end_time',$end_time);
|
||||
|
||||
$news = $m->getSysMsg('msg');
|
||||
$this->assign('news',$news);
|
||||
$ads['count'] = count(model("common/Tags")->listAds("mo-ads-index",99,86400));
|
||||
$ads['width'] = 'width:'.$ads['count'].'00%';
|
||||
$this->assign("ads", $ads);
|
||||
return $this->fetch('index');
|
||||
}
|
||||
/**
|
||||
* 楼层
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = new M();
|
||||
$rs = $m->pageQuery();
|
||||
if(isset($rs['goods'])){
|
||||
foreach ($rs['goods'] as $key =>$v){
|
||||
$rs['goods'][$key]['goodsImg'] = WSTImg($v['goodsImg'],2);
|
||||
}
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 猜你喜欢
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function guess_like(){
|
||||
$m = new M();
|
||||
$rs = $m->guess_like();
|
||||
if(isset($rs['goods'])){
|
||||
foreach ($rs['goods'] as $key =>$v){
|
||||
$rs['goods'][$key]['goodsImg'] = WSTImg($v['goodsImg'],2);
|
||||
}
|
||||
}
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 热卖推荐/
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getHotGoods(){
|
||||
$m = new M();
|
||||
$rs = $m->getHotGoods();
|
||||
foreach ($rs['Rows'] as &$v){
|
||||
$v['goodsImg'] = WSTImg($v['goodsImg'],2);
|
||||
}
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 猜你喜欢
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getIndexAds(){
|
||||
$m = new M();
|
||||
$rs['ads'] = $m->getIndexAds();
|
||||
$rs['top_img'] = $m->getIndexTopImg();
|
||||
$rs['cross_img'] = $m->getIndexCrossImg();
|
||||
return $rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换url
|
||||
*/
|
||||
public function transfor(){
|
||||
$data = input('param.');
|
||||
$url = $data['url'];
|
||||
unset($data['url']);
|
||||
echo Url($url,$data);
|
||||
}
|
||||
/**
|
||||
* 跳去登录之前的地址
|
||||
*/
|
||||
public function sessionAddress(){
|
||||
session('WST_MO_WlADDRESS',input('url'));
|
||||
return jsonReturn("", 1);
|
||||
}
|
||||
}
|
31
hyhproject/app/controller/Invoices.php
Executable file
31
hyhproject/app/controller/Invoices.php
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Invoices as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 发票信息控制器
|
||||
*/
|
||||
class Invoices extends Base{
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = new M();
|
||||
$rs = $m->pageQuery(5);// 移动版只显示5条发票信息
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public function add(){
|
||||
$m = new M();
|
||||
return $m->add();
|
||||
}
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public function edit(){
|
||||
$m = new M();
|
||||
return $m->edit();
|
||||
}
|
||||
}
|
15
hyhproject/app/controller/Juhui.php
Executable file
15
hyhproject/app/controller/Juhui.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Juhui extends Base{
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public function index(){
|
||||
return $this->fetch('juhui');
|
||||
}
|
||||
|
||||
}
|
59
hyhproject/app/controller/Logmoneys.php
Executable file
59
hyhproject/app/controller/Logmoneys.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 资金流水控制器
|
||||
*/
|
||||
class Logmoneys extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/**
|
||||
* 查看用户资金流水
|
||||
*/
|
||||
public function usermoneys(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$rs = model('Users')->getFieldsById($userId,['lockMoney','userMoney','payPwd']);
|
||||
$rs['isSetPayPwd'] = ($rs['payPwd']=='')?0:1;
|
||||
unset($rs['payPwd']);
|
||||
$rs['num'] = count(model('cashConfigs')->listQuery(0,$userId));
|
||||
$this->assign('rs',$rs);
|
||||
return $this->fetch('users/logmoneys/list');
|
||||
}
|
||||
/**
|
||||
* 资金流水
|
||||
*/
|
||||
public function record(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$rs = model('Users')->getFieldsById($userId,['lockMoney','userMoney','payPwd']);
|
||||
$this->assign('rs',$rs);
|
||||
return $this->fetch('users/logmoneys/record');
|
||||
}
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$data = model('LogMoneys')->pageQuery("",$userId);
|
||||
return jsonReturn("", 1,$data);
|
||||
}
|
||||
/**
|
||||
* 验证支付密码
|
||||
*/
|
||||
public function checkPayPwd(){
|
||||
return model('app/users')->checkPayPwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值[用户]
|
||||
*/
|
||||
public function toRecharge(){
|
||||
$payments = model('common/payments')->recharePayments('2');
|
||||
$this->assign('payments',$payments);
|
||||
//print_r($payments);
|
||||
$chargeItems = model('common/ChargeItems')->queryList();
|
||||
$this->assign('chargeItems',$chargeItems);
|
||||
return $this->fetch('users/recharge/recharge');
|
||||
}
|
||||
}
|
49
hyhproject/app/controller/Messages.php
Executable file
49
hyhproject/app/controller/Messages.php
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Messages as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商城消息控制器
|
||||
*/
|
||||
class Messages extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/**
|
||||
* 查看商城消息
|
||||
*/
|
||||
public function msgList(){
|
||||
$m = new M();
|
||||
exit(jsonReturn('',1,$m->pageQuery()));
|
||||
//return $this->fetch('users/messages/list');
|
||||
}
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = new M();
|
||||
return $m->pageQuery();
|
||||
}
|
||||
/**
|
||||
* 获取指定ID详情
|
||||
*/
|
||||
public function getById(){
|
||||
$m = new M();
|
||||
exit(jsonReturn('',1,$m->getById()));
|
||||
}
|
||||
/**
|
||||
* 删除消息
|
||||
*/
|
||||
public function del(){
|
||||
$m = new M();
|
||||
return $m->del();
|
||||
}
|
||||
/**
|
||||
* 批量删除消息
|
||||
*/
|
||||
public function batchDel(){
|
||||
$m = new M();
|
||||
return $m->batchDel();
|
||||
}
|
||||
}
|
39
hyhproject/app/controller/News.php
Executable file
39
hyhproject/app/controller/News.php
Executable file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Articles as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 新闻控制器
|
||||
*/
|
||||
class News extends Base{
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
public function view(){
|
||||
$articleId = (int)input('articleId');
|
||||
$this->assign('articleId',$articleId);
|
||||
return $this->fetch('articles/news_list');
|
||||
}
|
||||
/**
|
||||
* 获取商城快讯列表
|
||||
*/
|
||||
public function getNewsList(){
|
||||
$m = new M();
|
||||
$data = $m->getArticles();
|
||||
foreach($data as $k=>$v){
|
||||
$data[$k]['articleContent'] = strip_tags(html_entity_decode($v['articleContent']));
|
||||
$data[$k]['createTime'] = date('Y-m-d',strtotime($data[$k]['createTime']));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 查看详情
|
||||
*/
|
||||
public function getNews(){
|
||||
$m = new M();
|
||||
$data = $m->getNewsById();
|
||||
$data['articleContent']=htmlspecialchars_decode($data['articleContent']);
|
||||
$data['createTime'] = date('Y-m-d',strtotime($data['createTime']));
|
||||
return $data;
|
||||
}
|
||||
}
|
62
hyhproject/app/controller/Ordercomplains.php
Executable file
62
hyhproject/app/controller/Ordercomplains.php
Executable file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\OrderComplains as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 投诉控制器
|
||||
*/
|
||||
class orderComplains extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
public function complain(){
|
||||
$oId = (int)input('oId');
|
||||
$this->assign('oId',$oId);
|
||||
return $this->fetch('users/orders/orders_complains');
|
||||
}
|
||||
/**
|
||||
* 保存订单投诉信息
|
||||
*/
|
||||
public function saveComplain(){
|
||||
return model('OrderComplains')->saveComplain();
|
||||
}
|
||||
/**
|
||||
* 获取投诉类型
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getComplainCause(){
|
||||
exit(jsonReturn("",1,WSTDatas('ORDER_COMPLAINT')));
|
||||
}
|
||||
/**
|
||||
* 用户投诉列表
|
||||
*/
|
||||
public function index(){
|
||||
return $this->fetch('users/orders/list_complains');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户投诉列表
|
||||
*/
|
||||
public function complainByPage(){
|
||||
$m = model('OrderComplains');
|
||||
return $m->queryUserComplainByPage();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户查投诉详情
|
||||
*/
|
||||
public function getComplainDetail(){
|
||||
$rs = model('OrderComplains')->getComplainDetail(0);
|
||||
$annex = $rs['complainAnnex'];
|
||||
if($annex){
|
||||
foreach($annex as $k=>$v){
|
||||
$annex1[] = WSTImg($v,2);
|
||||
}
|
||||
$rs['complainAnnex'] = $annex1;
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
}
|
25
hyhproject/app/controller/Orderrefunds.php
Executable file
25
hyhproject/app/controller/Orderrefunds.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\OrderRefunds as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 订单退款控制器
|
||||
*/
|
||||
class Orderrefunds extends Base{
|
||||
/**
|
||||
* 用户申请退款
|
||||
*/
|
||||
public function refund(){
|
||||
$m = new M();
|
||||
$rs = $m->refund();
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 商家处理是否同意
|
||||
*/
|
||||
public function shopRefund(){
|
||||
$m = new M();
|
||||
$rs = $m->shopRefund();
|
||||
return $rs;
|
||||
}
|
||||
}
|
341
hyhproject/app/controller/Orders.php
Executable file
341
hyhproject/app/controller/Orders.php
Executable file
@ -0,0 +1,341 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Orders as M;
|
||||
use wstmart\common\model\Payments;
|
||||
|
||||
/**
|
||||
* ============================================================================
|
||||
* 订单控制器
|
||||
*/
|
||||
class Orders extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/*********************************************** 用户操作订单 ************************************************************/
|
||||
/**
|
||||
* 提醒发货
|
||||
*/
|
||||
public function noticeDeliver(){
|
||||
$m = new M();
|
||||
return $m->noticeDeliver();
|
||||
}
|
||||
/**
|
||||
* 提交订单
|
||||
*/
|
||||
public function submit(){
|
||||
$m = new M();
|
||||
$rs = $m->submit(3);
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 提交虚拟订单
|
||||
*/
|
||||
public function quickSubmit(){
|
||||
$m = new M();
|
||||
$rs = $m->quickSubmit();
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 在线支付方式
|
||||
*/
|
||||
public function succeed(){
|
||||
//获取支付方式
|
||||
$pa = new Payments();
|
||||
$payments = $pa->getByGroup('4',-1,true);//具体支付场景1pc,2wap,3微信,4app
|
||||
exit(jsonReturn('',1,$payments));
|
||||
// $this->assign('payments',$payments);
|
||||
// $this->assign('orderNo',input("get.orderNo"));
|
||||
// $this->assign('isBatch',(int)input("get.isBatch/d",0));
|
||||
// return $this->fetch("users/orders/orders_pay_list");
|
||||
}
|
||||
/**
|
||||
* 订单管理
|
||||
*/
|
||||
public function index(){
|
||||
$type = input('param.type','');
|
||||
$this->assign('type',$type);
|
||||
return $this->fetch("users/orders/orders_list");
|
||||
}
|
||||
public function findExpress(){
|
||||
$orderId = (int)input("orderId");
|
||||
$userId = $this->getUserId();
|
||||
$where['userId'] = $userId;
|
||||
if(!$orderId){
|
||||
$where['orderStatus'] = 1;//待收货状态
|
||||
$orderId = model('orders')->where($where)->max('orderId');
|
||||
}else{
|
||||
$where['orderId'] = $orderId;
|
||||
$find = model('orders')->where($where)->value('orderId');//杜绝别人查看物流情况
|
||||
if(!$find){
|
||||
exit(jsonReturn('获取失败',-1));
|
||||
}
|
||||
}
|
||||
if($orderId){
|
||||
$m = new \addons\kuaidi\model\Kuaidi();
|
||||
$rs = $m->getOrderExpress($orderId);
|
||||
$express = json_decode($rs, true);
|
||||
$state = isset($express["state"])?$express["state"]:'-1';
|
||||
$data = $m->getOrderInfo($orderId);
|
||||
$data["express"]["stateTxt"] = $this->getExpressState($state);
|
||||
$express["express"] = $data["express"];
|
||||
$express["goodsImg"] = $data["goodsImg"];
|
||||
exit(jsonReturn('',1,$express));
|
||||
}else{
|
||||
exit(jsonReturn('获取失败',-1));
|
||||
}
|
||||
|
||||
}
|
||||
public function getExpressState($state){
|
||||
$stateTxt = "";
|
||||
switch ($state) {
|
||||
case '0':$stateTxt="运输中";break;
|
||||
case '1':$stateTxt="揽件";break;
|
||||
case '2':$stateTxt="疑难";break;
|
||||
case '3':$stateTxt="收件人已签收";break;
|
||||
case '4':$stateTxt="已退签";break;
|
||||
case '5':$stateTxt="派件中";break;
|
||||
case '6':$stateTxt="退回";break;
|
||||
default:$stateTxt="暂未获取到状态";break;
|
||||
}
|
||||
return $stateTxt;
|
||||
}
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
public function getOrderList(){
|
||||
/*
|
||||
-3:拒收、退款列表
|
||||
-2:待付款列表
|
||||
-1:已取消订单
|
||||
0,1: 待收货
|
||||
2:待评价/已完成
|
||||
*/
|
||||
$flag = -1;
|
||||
$type = input('param.type');
|
||||
$status = [];
|
||||
switch ($type) {
|
||||
case 'waitPay':
|
||||
$status=[-2];
|
||||
break;
|
||||
case 'waitDeliver':
|
||||
$status=[0];
|
||||
break;
|
||||
case 'waitReceive':
|
||||
$status=[1];
|
||||
break;
|
||||
case 'waitAppraise':
|
||||
$status=[2];
|
||||
$flag=0;
|
||||
break;
|
||||
case 'finish':
|
||||
$status=[2];
|
||||
break;
|
||||
case 'abnormal': // 退款/拒收 与取消合并
|
||||
$status=[-1,-3];
|
||||
break;
|
||||
default:
|
||||
$status=[-5,-4,-3,-2,-1,0,1,2];
|
||||
break;
|
||||
}
|
||||
$m = new M();
|
||||
$rs = $m->userOrdersByPage($status,$flag);
|
||||
foreach($rs['Rows'] as $k=>$v){
|
||||
if(!empty($v['list'])){
|
||||
foreach($v['list'] as $k1=>$v1){
|
||||
$rs['Rows'][$k]['list'][$k1]['goodsImg'] = $v1['goodsImg'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// param.pagesize = 10;
|
||||
//param.page = Number( $('#currPage').val() ) + 1;
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
public function getDetail(){
|
||||
$m = new M();
|
||||
$rs = $m->getByView((int)input('id'));
|
||||
$rs['status'] = WSTLangOrderStatus($rs['orderStatus']);
|
||||
$rs['payInfo'] = WSTLangPayType($rs['payType']);
|
||||
$rs['deliverInfo'] = WSTLangDeliverType($rs['deliverType']);
|
||||
foreach($rs['goods'] as $k=>$v){
|
||||
$v['goodsImg'] = WSTImg($v['goodsImg'],3);
|
||||
}
|
||||
// 优惠券钩子
|
||||
hook('mobileDocumentOrderSummaryView',['rs'=>&$rs]);
|
||||
// 满就送钩子
|
||||
hook('mobileDocumentOrderViewGoodsPromotion',['rs'=>&$rs]);
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户确认收货
|
||||
*/
|
||||
public function receive(){
|
||||
$m = new M();
|
||||
$rs = $m->receive();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传凭证
|
||||
*/
|
||||
public function getCertificate(){
|
||||
$m = new M();
|
||||
$rs = $m->viewCertificate();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 用户上传凭证
|
||||
*/
|
||||
public function uploadCertificate(){
|
||||
$m = new M();
|
||||
$rs = $m->uploadCertificate();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 用户-评价页
|
||||
*/
|
||||
public function getOrderAppraise(){
|
||||
$m = model('Orders');
|
||||
$oId = (int)input('oId');
|
||||
//根据订单id获取 商品信息
|
||||
$data = $m->getOrderInfoAndAppr();
|
||||
$data['shopName']=model('shops')->getShopName($oId);
|
||||
$data['oId']=$oId;
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
/**
|
||||
* 用户取消订单
|
||||
*/
|
||||
public function cancellation(){
|
||||
$m = new M();
|
||||
$rs = $m->cancel();
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 获取取消订单原因
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getCancelCause(){
|
||||
exit(jsonReturn("",1,WSTDatas('ORDER_CANCEL')));
|
||||
}
|
||||
/**
|
||||
* 获取拒收订单原因
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getRejectCause(){
|
||||
exit(jsonReturn("",1,WSTDatas('ORDER_REJECT')));
|
||||
}
|
||||
/**
|
||||
* 获取申请退款原因
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getRefundCause(){
|
||||
exit(jsonReturn("",1,WSTDatas('REFUND_TYPE')));
|
||||
}
|
||||
/**
|
||||
* 用户拒收订单
|
||||
*/
|
||||
public function reject(){
|
||||
$m = new M();
|
||||
$rs = $m->reject();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户退款
|
||||
*/
|
||||
public function getRefund(){
|
||||
$orderId = (int)input('id');
|
||||
$userId = $this->getUserId();
|
||||
$orders = model('orders')->where(['orderId'=>$orderId,'userId'=>$userId,'dataFlag'=>1])->field('orderStatus')->find();
|
||||
if(empty($orders))return jsonReturn("无效的订单");
|
||||
$m = new M();
|
||||
$data = $m->getMoneyByOrder($orderId);
|
||||
exit(jsonReturn("",1,$data));
|
||||
}
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getExpress(){
|
||||
$express = model('Express')->listQuery();
|
||||
exit(jsonReturn("",1,$express));
|
||||
}
|
||||
/**
|
||||
* 用户-延时收货
|
||||
*/
|
||||
public function delay(){
|
||||
$m = new M();
|
||||
$rs = $m->delay();
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************** 商家操作订单 ************************************************************/
|
||||
|
||||
// /**
|
||||
// * 商家-查看订单列表
|
||||
// */
|
||||
// public function sellerOrder(){
|
||||
// $type = input('param.type','');
|
||||
// $this->assign('type',$type);
|
||||
// $express = model('Express')->listQuery();
|
||||
// $this->assign('express',$express);
|
||||
// return $this->fetch('users/sellerorders/orders_list');
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 商家-订单列表
|
||||
// */
|
||||
// public function getSellerOrderList(){
|
||||
// /*
|
||||
// -3:拒收、退款列表
|
||||
// -2:待付款列表
|
||||
// -1:已取消订单
|
||||
// 0: 待发货
|
||||
// 1,2:待评价/已完成
|
||||
// */
|
||||
// $type = input('param.type');
|
||||
// $status = [];
|
||||
// switch ($type) {
|
||||
// case 'waitPay':
|
||||
// $status=-2;
|
||||
// break;
|
||||
// case 'waitDeliver':
|
||||
// $status=0;
|
||||
// break;
|
||||
// case 'waitReceive':
|
||||
// $status=1;
|
||||
// break;
|
||||
// case 'waitDelivery':
|
||||
// $status=0;
|
||||
// break;
|
||||
// case 'finish':
|
||||
// $status=2;
|
||||
// break;
|
||||
// case 'abnormal': // 退款/拒收 与取消合并
|
||||
// $status=[-1,-3];
|
||||
// break;
|
||||
// default:
|
||||
// $status=[-5,-4,-3,-2,-1,0,1,2];
|
||||
// break;
|
||||
// }
|
||||
// $m = new M();
|
||||
// $rs = $m->shopOrdersByPage($status);
|
||||
// //dump($rs);die;
|
||||
// foreach($rs['Rows'] as $k=>$v){
|
||||
// if(!empty($v['list'])){
|
||||
// foreach($v['list'] as $k1=>$v1){
|
||||
// $rs['Rows'][$k]['list'][$k1]['goodsImg'] = $v1['goodsImg'];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return $rs;
|
||||
// }
|
||||
}
|
25
hyhproject/app/controller/Position.php
Executable file
25
hyhproject/app/controller/Position.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Position as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 地区控制器
|
||||
*/
|
||||
class Position extends Base{
|
||||
/**
|
||||
* 获取地区名字
|
||||
*/
|
||||
public function getAreaName(){
|
||||
$m = new M();
|
||||
$rs = $m->getAreaName();
|
||||
exit(jsonReturn('', 1,$rs));
|
||||
}
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
public function listQuery(){
|
||||
$m = new M();
|
||||
$rs = $m->listQuery();
|
||||
exit(jsonReturn('', 1,$rs));
|
||||
}
|
||||
}
|
45
hyhproject/app/controller/Qlgpay.php
Executable file
45
hyhproject/app/controller/Qlgpay.php
Executable file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Orders as OM;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 全亮共支付
|
||||
*/
|
||||
class Qlgpay extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/**
|
||||
* 跳去支付页面
|
||||
*/
|
||||
public function payment(){
|
||||
$data = [];
|
||||
$data['orderNo'] = input('orderNo');
|
||||
$data['isBatch'] = (int)input('isBatch');
|
||||
$data['userId'] = (int)session('WST_USER.userId');
|
||||
$m = new OM();
|
||||
$rs = $m->getOrderPayInfo($data);//获取订单金额以及用户钱包金额
|
||||
|
||||
$pay['list'] = $m->getByUnique();// 根据订单唯一流水获取订单信息
|
||||
|
||||
if(empty($rs)){//已支付或者找不到此订单
|
||||
exit(jsonReturn('读取失败',-1));
|
||||
}else{
|
||||
$pay['needPay'] = $rs['needPay'];//需付款
|
||||
|
||||
}
|
||||
$userId = $this->getUserId();
|
||||
$m = new OM();
|
||||
$pay = array_merge($pay,$m->getPayMoney($userId,$pay['needPay']));
|
||||
exit(jsonReturn('',1,$pay));
|
||||
|
||||
}
|
||||
/*
|
||||
* 钱包支付
|
||||
*/
|
||||
public function payByQlg(){
|
||||
$m = new OM();
|
||||
exit(json_encode($m->payByQlg()));
|
||||
}
|
||||
}
|
145
hyhproject/app/controller/Shoporders.php
Executable file
145
hyhproject/app/controller/Shoporders.php
Executable file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Orders as M;
|
||||
// use think\Loader;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 订单控制器
|
||||
*/
|
||||
|
||||
class Shoporders extends Base{
|
||||
// protected $beforeActionList = [
|
||||
// 'checksession', //在任何操作执行前执行checksession方法
|
||||
// 'islogin' => ['except'=>'login'], //在除login之外的其他方法执行前先执行islogin方法
|
||||
// 'removesession' => ['only'=>'logout'], //在logout执行前先执行removesession
|
||||
// ];
|
||||
protected $beforeActionList = [
|
||||
'checkAuth',//=>['only'=>'shopjoin,getshopjoininfo'],
|
||||
'checkDataAuth'
|
||||
];
|
||||
|
||||
/**
|
||||
* 查看订单凭证
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function viewCertificate(){
|
||||
$m = new M();
|
||||
$rs = $m->viewCertificate(1);
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 商家-订单列表
|
||||
*/
|
||||
public function getSellerOrderList(){
|
||||
/*
|
||||
-3:拒收、退款列表
|
||||
-2:待付款列表
|
||||
-1:已取消订单
|
||||
0: 待发货
|
||||
1,2:待评价/已完成
|
||||
*/
|
||||
$type = input('param.type');
|
||||
$status = [];
|
||||
$shopConfirm = -1;
|
||||
switch ($type) {
|
||||
case 'waitPay':
|
||||
$status=-2;
|
||||
break;
|
||||
case 'waitDeliver':
|
||||
$status=0;
|
||||
$shopConfirm = 1;
|
||||
break;
|
||||
case 'waitConfirm':
|
||||
$status=0;
|
||||
$shopConfirm = '0,2';
|
||||
break;
|
||||
case 'waitReceive':
|
||||
$status=1;
|
||||
break;
|
||||
case 'finish':
|
||||
$status=2;
|
||||
break;
|
||||
case 'abnormal': // 退款/拒收 与取消合并
|
||||
$status=[-1,-3];
|
||||
break;
|
||||
default:
|
||||
$status=[-5,-4,-3,-2,-1,0,1,2];
|
||||
break;
|
||||
}
|
||||
$m = new M();
|
||||
$rs = $m->shopOrderList($status,0,$shopConfirm);
|
||||
//dump($rs);die;
|
||||
foreach($rs['Rows'] as $k=>$v){
|
||||
if(!empty($v['list'])){
|
||||
foreach($v['list'] as $k1=>$v1){
|
||||
$rs['Rows'][$k]['list'][$k1]['goodsImg'] = $v1['goodsImg'];
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 订单确认
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function orderConfirm(){
|
||||
$m = new M();
|
||||
$rs = $m->orderConfirm();
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 查看未提交和已提交凭证
|
||||
*/
|
||||
public function getCertificate(){
|
||||
$m = new M();
|
||||
$rs = $m->getShopCertificate();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获取已提交的凭证信息
|
||||
*/
|
||||
public function getCertificateInfo(){
|
||||
$m = Model('common/Table');
|
||||
$m->setTable('order_shop_certificate');
|
||||
$id = (int)input('id');
|
||||
$rs = $m->getInfo(['id'=>$id,'shopId'=>(int)session('WST_USER.shopId')],'id,content,imgUrl');
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 商家上传凭证
|
||||
*/
|
||||
public function uploadCertificate(){
|
||||
$m = new M();
|
||||
$rs = $m->uploadShopCertificate();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 商家发货
|
||||
*/
|
||||
public function deliver(){
|
||||
$m = new M();
|
||||
$rs = $m->deliver();
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 商家修改订单价格
|
||||
*/
|
||||
// public function editOrderMoney(){
|
||||
// $m = new M();
|
||||
// $rs = $m->editOrderMoney();
|
||||
// return $rs;
|
||||
// }
|
||||
/**
|
||||
* 商家-操作退款
|
||||
*/
|
||||
public function toShopRefund(){
|
||||
return model('OrderRefunds')->getRefundMoneyByOrder((int)input('id'));
|
||||
}
|
||||
/**
|
||||
* 商家处理是否同意退款
|
||||
*/
|
||||
public function shopRefund(){
|
||||
$rs = model('OrderRefunds')->shopRefund();
|
||||
exit(json_encode($rs)) ;
|
||||
}
|
||||
}
|
76
hyhproject/app/controller/Shopping.php
Executable file
76
hyhproject/app/controller/Shopping.php
Executable file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Shopping as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 逛商铺处理类
|
||||
*/
|
||||
class Shopping extends Base{
|
||||
|
||||
/**
|
||||
* 获取助微吧轮播
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getHelpCarousel(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->getHelpCarousel()));
|
||||
}
|
||||
/**
|
||||
* 搜索助微吧商品列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getHelpShops(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->getHelpShops()));
|
||||
}
|
||||
public function searchHelpGoods(){
|
||||
$m = new M();
|
||||
exit(jsonReturn($m->searchHelpGoods()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取逛商都/助微吧推荐商品
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getGoods(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->getGoods()));
|
||||
// $m = Model('common/Table');
|
||||
// $m->setTable('shops');
|
||||
}
|
||||
/**
|
||||
* 获取逛商铺轮播
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getCarousel(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->getCarousel()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取逛商铺列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getShops(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->getShops()));
|
||||
}
|
||||
/**
|
||||
* 获取商铺首页
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getShopInfo(){
|
||||
$m = Model('shops');
|
||||
exit(json_encode($m->getShopIndex()));
|
||||
// $m = Model('common/Table');
|
||||
// $m->setTable('shops');
|
||||
}
|
||||
/**
|
||||
* 获取店铺首页商品列表
|
||||
*/
|
||||
public function getShopIndexGoodsList(){
|
||||
$m = Model('common/Shops');
|
||||
$rs = $m->getShopIndexGoodsList(0,'goodsId,goodsImg,goodsName,shopPrice,saleNum,discountRate','goodsOrder DESC,saleNum DESC,goodsId DESC');
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
}
|
646
hyhproject/app/controller/Shops.php
Executable file
646
hyhproject/app/controller/Shops.php
Executable file
@ -0,0 +1,646 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\home\model\Goods;
|
||||
use wstmart\common\model\GoodsCats;
|
||||
use wstmart\common\model\Table as M;
|
||||
use wstmart\common\model\Shops as SM;
|
||||
// use think\Loader;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 门店控制器
|
||||
*/
|
||||
|
||||
class Shops extends Base{
|
||||
// protected $beforeActionList = [
|
||||
// 'checksession', //在任何操作执行前执行checksession方法
|
||||
// 'islogin' => ['except'=>'login'], //在除login之外的其他方法执行前先执行islogin方法
|
||||
// 'removesession' => ['only'=>'logout'], //在logout执行前先执行removesession
|
||||
// ];
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'=>['except'=>'pagequery'],
|
||||
'checkDataAuth'=>['only'=>'setspecs,getspecs,getspeccats,delspecset,getgoodsspeccats,addgoods,editgoods,getgoodsinfo,uploadshopimg,delgoods,delshop,shopinfo,getsellerorderlist,orderconfirm,getgoodslist,viewcertificate,userupdate,getshopimg,getbank'],
|
||||
'checkShopAuth' => ['except'=>'shopjoin,getshopjoininfo,usershoplist,pagequery'],
|
||||
];
|
||||
/**
|
||||
* 获取商家入驻信息
|
||||
*/
|
||||
public function getShopJoinInfo(){
|
||||
$where['userId'] = $this->getUserId();
|
||||
$where['shopId'] = (int)input('post.shopId');
|
||||
$where['dataFlag'] = 1;
|
||||
$m = new M();
|
||||
$m->setTable('shops');
|
||||
$shopInfo = $m->getInfo($where,'shopName,userName,phone,provinceId,cityId,countyId,townId,villageId,shopAddress,lng,lat,bankName,accountName,bankNo,idCardFrontImg,idCardBackImg,commissionImg,businessLicenceImg,confirmationImg');
|
||||
if($shopInfo){
|
||||
exit(jsonReturn('',1,$shopInfo));
|
||||
}
|
||||
exit(jsonReturn('获取失败!'));
|
||||
}
|
||||
/**
|
||||
* 商家入驻
|
||||
*/
|
||||
public function shopJoin(){
|
||||
$data = input('post.');
|
||||
$validate = \think\Loader::validate('Shops');
|
||||
if(!$validate->scene('join')->check($data)){
|
||||
exit(jsonReturn($validate->getError()));
|
||||
}
|
||||
$data['shopType'] = (int)input('post.shopType',1);
|
||||
$data['userId'] = $this->getUserId();
|
||||
$data['status']=0;
|
||||
$m = new M();
|
||||
$m->setTable('shops');
|
||||
$shopId = isset($data['shopId']) ? $data['shopId'] : 0;
|
||||
if($shopId){
|
||||
//unset($data['shopId']);
|
||||
$isSuccess = $m->updateInfo(['shopId'=>$shopId,'userId'=>$data['userId']],$data);
|
||||
//$m->insertInfo($data);
|
||||
}else{
|
||||
if($m->getField(['userId'=>$data['userId'],'shopName'=>$data['shopName'],'dataFlag'=>1],'shopId')){
|
||||
exit(jsonReturn('请不要重复提交'));
|
||||
}
|
||||
$data['createTime'] = time();
|
||||
$isSuccess = $m->insertInfo($data);
|
||||
}
|
||||
if(false !== $isSuccess){
|
||||
$userPhone = getAdminPhone();
|
||||
$tpl = WSTMsgTemplates('PHONE_ADMIN_SHOP_APPLAY_NOTICE');
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['name'=>$this->user['loginName']]];
|
||||
$m = Model('common/LogSms');
|
||||
$rv = $m->sendSMS(0,$userPhone,$params,'PHONE_ADMIN_SHOP_APPLAY_NOTICE',0);
|
||||
}
|
||||
exit(jsonReturn('提交成功,请等待系统审核',1));
|
||||
}else{
|
||||
exit(jsonReturn('操作失败,请重试'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 商家列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function userShopList(){
|
||||
$m = new M();
|
||||
$m->setTable('shops');
|
||||
$where['userId'] = $this->getUserId();
|
||||
$where['shopType'] = (int)input('post.shopType',1);
|
||||
//$where['status']=1;
|
||||
$where['dataFlag']=1;
|
||||
$shops = $m->getList($where,'shopId,shopName,shopImg,status');
|
||||
exit(jsonReturn('',1,$shops));
|
||||
}
|
||||
/**
|
||||
* 获取商家信息
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function shopInfo(){
|
||||
$m = new SM();
|
||||
$rs = $m->shopInfo();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获取商家图片
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getShopImg(){
|
||||
$m = new SM();
|
||||
$rs = $m->getShopImg();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* [删除店铺]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function delShop(){
|
||||
$shopId=(int)input('post.shopId');
|
||||
if($shopId){
|
||||
$payPwd = input('post.payPwd');
|
||||
if(md5($payPwd) != $this->user['payPwd']){
|
||||
exit(jsonReturn('密码错误'));
|
||||
}
|
||||
$m = new M();
|
||||
$m->setTable('shops');
|
||||
$rs = $m->updateInfo(['shopId'=>(int)$shopId,'userId'=>$this->getUserId()],['dataFlag'=>-1]);
|
||||
if(false !== $rs){
|
||||
exit(jsonReturn('删除店铺成功',1));
|
||||
}
|
||||
}
|
||||
exit(jsonReturn('删除店铺失败'));
|
||||
}
|
||||
/**
|
||||
* 添加规格
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function setSpecs(){
|
||||
$m = new SM();
|
||||
$rs = $m->setSpecs($this->getUserId());
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获名总规格名
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getSpecs(){
|
||||
$m = new SM();
|
||||
$rs = $m->getSpecs();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 删除总规格名
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function delSpecSet(){
|
||||
$m = new M();
|
||||
$m->setTable('spec_set');
|
||||
$rs = $m->updateInfo(['id'=>(int)input('post.id'),'userId'=>$this->getUserId()],['dataFlag'=>-1]);
|
||||
if(false !== $rs){
|
||||
exit(jsonReturn('删除成功!',1));
|
||||
}
|
||||
exit(jsonReturn('删除失败!'));
|
||||
}
|
||||
/**
|
||||
* 获名总规格下属性名和属性值
|
||||
*/
|
||||
public function getSpecCats(){
|
||||
$m = new SM();
|
||||
$rs = $m->getSpecCats($this->getUserId());
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获名商品总规格下属性名和属性值
|
||||
*/
|
||||
public function getGoodsSpecCats(){
|
||||
$m = new SM();
|
||||
$rs = $m->getGoodsSpecCats($this->getUserId());
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获名商品分类
|
||||
*/
|
||||
public function getGoodsCats(){
|
||||
$pid = (int)input('post.pid');
|
||||
$m = Model('common/GoodsCats');
|
||||
$rs = $m->listQuery($pid,-1,'catId,catName');
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 添加商品
|
||||
*/
|
||||
public function addGoods(){
|
||||
$m = new SM();
|
||||
$rs = $m->addGoods();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 编辑商品
|
||||
*/
|
||||
public function editGoods(){
|
||||
$m = new SM();
|
||||
$rs = $m->editGoods();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 申请商超/商厦/商都
|
||||
* @param [type] $userId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function userUpdate(){
|
||||
$m = new SM();
|
||||
if(2 == $this->user['authType'] && 1 == $this->user['userType'] ){
|
||||
$rs = $m->userUpdate($this->getUserId());
|
||||
}else{
|
||||
$rs = WSTReturn('仅合作认证用户并开店成功后可申请');
|
||||
}
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获取申请商超/商厦/商都信息
|
||||
* @param [type] $userId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getUserUpdate(){
|
||||
$m = new SM();
|
||||
if(2 == $this->user['authType'] && 1 == $this->user['userType'] ){
|
||||
$rs = $m->getUserUpdate($this->getUserId());
|
||||
}else{
|
||||
$rs = WSTReturn('仅合作认证用户并开店成功后可申请'.$this->user['authType']);
|
||||
}
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
public function getBank(){
|
||||
$m = new M();
|
||||
$m->setTable('shops');
|
||||
$bankInfo = $m->getInfo(['shopId'=>(int)input('post.shopId')],'bankName,accountName,bankNo');
|
||||
exit(jsonReturn('',1,$bankInfo));
|
||||
}
|
||||
//商家申请提现
|
||||
public function withdrawal(){
|
||||
$rs = Model('Common/CashDraws')->drawWangByShop();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获取商品信息
|
||||
*/
|
||||
public function getGoodsInfo(){
|
||||
$m = new SM();
|
||||
$rs = $m->getGoodsInfo();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传店铺主图和轮播图
|
||||
*/
|
||||
public function uploadShopImg(){
|
||||
$m = new SM();
|
||||
$rs = $m->uploadShopImg();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
*/
|
||||
public function getGoodsList(){
|
||||
$m = new SM();
|
||||
$rs = $m->getGoodsList();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 获取店铺首页商品列表
|
||||
*/
|
||||
public function getShopIndexGoodsList(){
|
||||
$m = new SM();
|
||||
$rs = $m->getShopIndexGoodsList(0,'goodsImg,goodsName,shopPrice,saleNum','goodsOrder DESC,saleNum DESC');
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*/
|
||||
public function delGoods(){
|
||||
$goodsId = (int)input('post.goodsId/d');
|
||||
if($goodsId){
|
||||
$m = new M();
|
||||
$m->setTable('goods');
|
||||
if(false !== $m->updateInfo(['goodsId'=>$goodsId],['dataFlag'=>-1])){
|
||||
exit(jsonReturn('删除成功',1));
|
||||
}
|
||||
|
||||
}
|
||||
exit(jsonReturn('删除失败'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 店铺公告页
|
||||
*/
|
||||
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');
|
||||
$data = $s->getShopSummary((int)session('WST_USER.shopId'));
|
||||
$this->assign('data',$data);
|
||||
return $this->fetch('shops/index');
|
||||
}
|
||||
/**
|
||||
* 店铺列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$m = model('shops');
|
||||
$rs = $m->pageQuery(input('pagesize/d'));
|
||||
foreach ($rs['Rows'] as $key =>$v){
|
||||
$rs['Rows'][$key]['shopImg'] = WSTImg($v['shopImg'],3);
|
||||
}
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 店铺街
|
||||
*/
|
||||
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 = \think\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 = \think\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 = \think\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 = think\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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
hyhproject/app/controller/Switchs.php
Executable file
22
hyhproject/app/controller/Switchs.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 关闭提示处理控制器
|
||||
*/
|
||||
use think\Controller;
|
||||
class Switchs extends Controller{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
WSTConf('CONF',WSTConfig());
|
||||
$this->assign("v",WSTConf('CONF.wstVersion')."_".WSTConf('CONF.wstPcStyleId'));
|
||||
}
|
||||
protected function fetch($template = '', $vars = [], $replace = [], $config = []){
|
||||
$style = WSTConf('CONF.wstappStyle')?WSTConf('CONF.wstappStyle'):'default';
|
||||
$replace['__APP__'] = str_replace('/index.php','',\think\Request::instance()->root()).'/wstmart/app/view/'.$style;
|
||||
return $this->view->fetch($style."/".$template, $vars, $replace, $config);
|
||||
}
|
||||
public function index(){
|
||||
return $this->fetch('error_switch');
|
||||
}
|
||||
}
|
13
hyhproject/app/controller/Tag.php
Executable file
13
hyhproject/app/controller/Tag.php
Executable file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Tag as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 地区控制器
|
||||
*/
|
||||
class Tag extends Base{
|
||||
public function articleDetail(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->articleDetail()));
|
||||
}
|
||||
}
|
13
hyhproject/app/controller/Tags.php
Executable file
13
hyhproject/app/controller/Tags.php
Executable file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Tags as M;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 标签业务处理类
|
||||
*/
|
||||
class Tags extends Base{
|
||||
public function articleDetail(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->articleDetail()));
|
||||
}
|
||||
}
|
14
hyhproject/app/controller/Tmp.php
Executable file
14
hyhproject/app/controller/Tmp.php
Executable file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Aliyunoss as M;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 地区控制器
|
||||
*/
|
||||
class Tmp extends Base{
|
||||
public function index(){
|
||||
$m = new M();
|
||||
dump($m->getInfo('upload/goods/2018-03/5ab477676fccc.jpg'));
|
||||
}
|
||||
}
|
211
hyhproject/app/controller/Unionpays.php
Executable file
211
hyhproject/app/controller/Unionpays.php
Executable file
@ -0,0 +1,211 @@
|
||||
<?php
|
||||
namespace wstmart\app\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("app/orders/index","",true,true);
|
||||
$config["backUrl"] = url("app/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 toUnionpay(){
|
||||
|
||||
$payObj = input("payObj/s");
|
||||
$m = new OM();
|
||||
$obj = array();
|
||||
$data = array();
|
||||
$orderAmount = 0;
|
||||
$orderId = "";
|
||||
$extra_param = "";
|
||||
if($payObj=="recharge"){//充值
|
||||
$orderAmount = input("needPay/d");
|
||||
$targetType = (int)input("targetType/d");
|
||||
$targetId = (int)session('WST_USER.userId');
|
||||
if($targetType==1){//商家
|
||||
$targetId = (int)session('WST_USER.shopId');
|
||||
}
|
||||
$data["status"] = $orderAmount>0?1:-1;
|
||||
$orderId = WSTOrderNo();
|
||||
$extra_param = $payObj."|".$targetId."|".$targetType;
|
||||
|
||||
}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' => '08', //渠道类型,07-PC,08-手机
|
||||
'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];
|
||||
$obj = array ();
|
||||
$obj["trade_no"] = $_POST['trade_no'];
|
||||
$obj["out_trade_no"] = $_POST["out_trade_no"];;
|
||||
$obj["targetId"] = $targetId;
|
||||
$obj["targetType"] = $targetType;
|
||||
$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"){//充值
|
||||
$this->redirect(url("app/users/index"));
|
||||
}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);
|
||||
$this->redirect(url("app/orders/index"));
|
||||
}
|
||||
}else {
|
||||
$this->error('支付失败');
|
||||
}
|
||||
}else {
|
||||
$this->error('支付失败');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
66
hyhproject/app/controller/Useraddress.php
Executable file
66
hyhproject/app/controller/Useraddress.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\UserAddress as M;
|
||||
/**
|
||||
* 用户地址控制器
|
||||
*/
|
||||
class UserAddress extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/**
|
||||
* 获取地址信息
|
||||
*/
|
||||
public function getList(){
|
||||
$m = new M();
|
||||
$userId = session('WST_USER.userId');
|
||||
$data['addressList'] = $m->listQuery($userId);
|
||||
//获取省级地区信息
|
||||
//$data['area'] = model('app/Areas')->listQuery(0);
|
||||
exit(jsonReturn('',1,$data));
|
||||
//$this->assign('type', (int)input('type'));
|
||||
//$this->assign('addressId', (int)input('addressId'));//结算选中的地址
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取地址信息
|
||||
*/
|
||||
public function getById(){
|
||||
$m = new M();
|
||||
$data = $m->getById(input('post.addressId/d'));
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
public function getArea(){
|
||||
//获取省级地区信息
|
||||
$data['area'] = model('app/Areas')->listQuery(0);
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置为默认地址
|
||||
*/
|
||||
public function setDefault(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->setDefault()));
|
||||
}
|
||||
/**
|
||||
* 新增/编辑地址
|
||||
*/
|
||||
public function edits(){
|
||||
$m = new M();
|
||||
if(input('post.addressId/d')){
|
||||
$rs = $m->edit();
|
||||
}else{
|
||||
$rs = $m->add();
|
||||
}
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 删除地址
|
||||
*/
|
||||
public function del(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->del()));
|
||||
}
|
||||
}
|
841
hyhproject/app/controller/Users.php
Executable file
841
hyhproject/app/controller/Users.php
Executable file
@ -0,0 +1,841 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Users as M;
|
||||
use wstmart\app\model\Favorites;
|
||||
use wstmart\app\model\Messages;
|
||||
use wstmart\common\model\LogSms;
|
||||
use wstmart\common\model\Users as MUsers;
|
||||
use wstmart\common\model\UserTrees;
|
||||
use think\Collection;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 用户控制器
|
||||
*/
|
||||
class Users extends Base{
|
||||
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth' => ['except'=>'checklogin,login,check_login_name,get_puser_info,register,getverify,toregister,forgetpass,forgetpasst,forgetpasss,forgetpassf,findpass,getfindphone,resetpass,getphoneverifycode,checkuserphone']// 访问这些except下的方法不需要执行前置操作
|
||||
];
|
||||
/**
|
||||
* 我的亲人投资列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function familyInvestmentList(){
|
||||
//if(0 == $this->user['authType'])exit(jsonReturn('请先实名认证'));
|
||||
$m = Model('common/Table');
|
||||
|
||||
$userId = $this->getUserId();
|
||||
$list = db('auth_company_partner p')
|
||||
->join('__AUTH_FAMILY_PERSONAL__ f','f.familyId=p.partnerId')
|
||||
->join('__AUTH_COMPANY__ c','c.userId=p.userId')
|
||||
->where(['f.userId'=>$userId,'p.dataFlag'=>1,'c.status'=>1])
|
||||
->field('c.userId,c.companyName,c.headImg,c.companyAddress,c.createTime,p.positionName,p.stake')
|
||||
->select();
|
||||
//->paginate(input('pageSize/d',10))->toArray();
|
||||
$m->setTable('auth_company_partner');
|
||||
foreach ($list as &$v) {
|
||||
$v['headImg'] = WSTImg($v['headImg'],3);
|
||||
$v['count'] = $m->getCount(['userId'=>$v['userId'],'dataFlag'=>1],'id');
|
||||
}
|
||||
exit(jsonReturn('',1,$list));
|
||||
}
|
||||
//合作认证详细信息
|
||||
public function investmentInfo(){
|
||||
$userId = input('userId');
|
||||
$m = Model('common/Table');
|
||||
$m->setTable('auth_company_partner');
|
||||
$list = $m->getList(['userId'=>$userId,'dataFlag'=>1],'uName,positionName,businessImg,stake,createTime');
|
||||
exit(jsonReturn('',1,$list));
|
||||
}
|
||||
/**
|
||||
* 获取合作券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getInvestmentMoney(){
|
||||
$userId = input('userId');
|
||||
$field = 'productNum,couponsNum';
|
||||
$m = Model('common/Table');
|
||||
$m->setTable('users');
|
||||
$info = $m->getInfo(['userId'=>$userId],$field);
|
||||
exit(jsonReturn('',1,$info));
|
||||
|
||||
}
|
||||
/**
|
||||
* 分配券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function distributionInvestmentMoney(){
|
||||
$m = new MUsers();
|
||||
$rs = $m->distributionInvestmentMoney();
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测会员名
|
||||
*/
|
||||
public function check_login_name(){
|
||||
$loginName = input('post.loginName');
|
||||
if(strlen($loginName) < 6 ){
|
||||
exit(jsonReturn('用户名不能小于6个字符!'));
|
||||
}
|
||||
exit(json_encode(WSTCheckLoginKey($loginName)));
|
||||
}
|
||||
/**
|
||||
* 获取券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getMoney(){
|
||||
$type = (int)input('post.type');
|
||||
$typeName = ['0'=>'productNum,couponsNum,wangNum','1'=>'productNum','2'=>'couponsNum','3'=>'wangNum'];
|
||||
if(array_key_exists($type, $typeName)){
|
||||
$m = Model('common/Table');
|
||||
$m->setTable('users');
|
||||
$info = $m->getInfo(['userId'=>$this->getUserId()],$typeName[$type]);
|
||||
exit(jsonReturn('',1,$info));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取推荐人信息
|
||||
*/
|
||||
public function get_puser_info(){
|
||||
$pName = trim(input('post.pName'));
|
||||
$pInfo = getUserInfo(['loginName|userPhone'=>$pName],'loginName,userPhone');
|
||||
if($pInfo){
|
||||
exit(jsonReturn('',1,$pInfo));
|
||||
}
|
||||
exit(jsonReturn('未找到推荐信息'.$pName));
|
||||
}
|
||||
/**
|
||||
* 我家朋友
|
||||
*/
|
||||
public function myFriend(){
|
||||
$m = new MUsers();
|
||||
$userId = $this->getUserId();
|
||||
$rs = $m->myFriend($userId);
|
||||
$rs['user'] = ['userId'=>$userId,'loginName'=>$this->user['loginName']];
|
||||
$rs['share_url'] = 'http://t.ect99.com/mobile/reg/reg.html?pName='.$this->user['loginName'];
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
/**
|
||||
* 我家朋友列表
|
||||
*/
|
||||
public function myFriendList(){
|
||||
$m = new MUsers();
|
||||
$userId = $this->getUserId();
|
||||
$rs = $m->myFriendList($userId);
|
||||
exit(jsonReturn('',1,$rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员登录
|
||||
*/
|
||||
public function checkLogin(){
|
||||
$m = new M();
|
||||
$rs = $m->checkLogin(3);
|
||||
$rs['url'] = session('WST_MO_WlADDRESS');
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
public function get_name_and_money(){
|
||||
$data['name'] = session('WST_USER.loginName');
|
||||
$data['money'] = session('WST_USER.userMoney');
|
||||
$data['userECT'] = session('WST_USER.userECT');
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
/**
|
||||
* 会员注册
|
||||
*/
|
||||
public function register(){
|
||||
$m = new M();
|
||||
$rs = $m->regist(3);
|
||||
$rs['url'] = session('WST_MO_WlADDRESS');
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
/**
|
||||
* 手机号码是否存在
|
||||
*/
|
||||
public function checkUserPhone(){
|
||||
$userPhone = input("post.userPhone");
|
||||
$m = new M();
|
||||
$rs = $m->checkUserPhone($userPhone,$this->getUserId());
|
||||
if($rs["status"]!=1){
|
||||
exit(jsonReturn("手机号已注册",-1));
|
||||
}else{
|
||||
exit(jsonReturn("",1));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
public function getPhoneVerifyCode(){
|
||||
$userPhone = input("post.userPhone");
|
||||
$rs = array();
|
||||
if(!WSTIsPhone($userPhone)){
|
||||
exit(jsonReturn("手机号格式不正确!"));
|
||||
}
|
||||
$m = new M();
|
||||
$rs = $m->checkUserPhone($userPhone,0,'loginName');
|
||||
//是否是推荐人注册 0不是,1是
|
||||
if(0 == WSTConf('CONF.referrerOpen')){
|
||||
if($rs["status"]!=1){
|
||||
exit(jsonReturn("手机号已存在!"));
|
||||
}else{
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$tpl = WSTMsgTemplates('PHONE_USER_REGISTER_VERFIY');
|
||||
}
|
||||
}else{
|
||||
if($rs["status"]==1){
|
||||
exit(jsonReturn("手机号不存在!"));
|
||||
}else{
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$tpl = WSTMsgTemplates('PHONE_PUSER_REGISTER_VERFIY');
|
||||
}
|
||||
}
|
||||
$rv['status'] = -1;
|
||||
$rv['msg'] = '发送失败';
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['name'=>$rs['data']['loginName'],'code'=>$phoneVerify]];
|
||||
$m = new LogSms();
|
||||
$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyCode',$phoneVerify);
|
||||
}
|
||||
if($rv['status']==1){
|
||||
session('VerifyCode_userPhone',$phoneVerify);
|
||||
session('VerifyCode_userPhone_Time',time());
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 会员中心
|
||||
*/
|
||||
public function index(){
|
||||
$userId = $this->getUserId();
|
||||
$m = new M();
|
||||
$user = $m->getById($userId);
|
||||
if($user['userName']=='')
|
||||
$user['userName']=$user['loginName'];
|
||||
$this->assign('user', $user);
|
||||
|
||||
//商城未读消息的数量 及 各订单状态数量
|
||||
$data = model('index')->getSysMsg('msg','order');
|
||||
$this->assign('data',$data);
|
||||
return $this->fetch('users/index');
|
||||
}
|
||||
/**
|
||||
* 会员中心
|
||||
*/
|
||||
public function getIndex(){
|
||||
$userId = $this->getUserId();
|
||||
$m = Model('common/Table');
|
||||
$m->setTable('user_vouchers_summary');
|
||||
$data = $m->getInfo(['userId'=>$userId],'expectedProductNum,expectedCouponsNum');
|
||||
$m->setTable('shops');
|
||||
$shopIds = $m->getColumn(['status'=>1,'userId'=>$userId],'shopId');
|
||||
if($shopIds){
|
||||
$m->setTable('orders');
|
||||
$data['expectedWangNum'] = $m->getField(['shopId'=>['in',$shopIds],'orderStatus'=>['BETWEEN','0,1']],'SUM((productNum - productHandlingFee - productTaxFee) + (couponsNum - couponsHandlingFee - couponsTaxFee) + wangNum)');//预获旺旺券
|
||||
}else{
|
||||
$data['expectedWangNum'] = 0;//预获旺旺券
|
||||
}
|
||||
$data['expectedProductNum'] = isset($data['expectedProductNum']) ? $data['expectedProductNum'] : 0;
|
||||
$data['expectedCouponsNum'] = isset($data['expectedCouponsNum']) ? $data['expectedCouponsNum'] : 0;
|
||||
$data['user'] = getUserInfo(['userId'=>$userId],'userId,loginName,userType,userName,trueName,userPhone,userPhoto,userStatus,token,userLevel,authType,couponsNum,productNum,wangNum');
|
||||
if(1 == $this->user['authType']){
|
||||
$m->setTable('auth_personal');
|
||||
$data['user']['userPhoto'] = $m->getField(['userId'=>$userId,'status'=>1],'headImg');
|
||||
}elseif(2 == $this->user['authType']){
|
||||
$m->setTable('auth_company`');
|
||||
$data['user']['userPhoto'] = $m->getField(['userId'=>$userId,'status'=>1],'headImg');
|
||||
}
|
||||
//$data['favoritesNum'] = $this->getFavoritesNum(0);
|
||||
//商城未读消息的数量 及 各订单状态数量
|
||||
//$data['sysMsg'] = $this->getSysMsg(0);
|
||||
|
||||
exit(jsonReturn("",1,$data));
|
||||
}
|
||||
/**
|
||||
* 设置点赞记数
|
||||
*/
|
||||
public function setRewardLike(){
|
||||
$rewardId = (int)input("param.rewardId/d",0);
|
||||
$isLike = (int)input("param.isLike/d",0);
|
||||
if($rewardId){
|
||||
$s = model('shops');
|
||||
$s->setRewardLike($rewardId,$this->getUserId(),$isLike);
|
||||
exit(jsonReturn('',1));
|
||||
}
|
||||
exit(jsonReturn('设置失败'));
|
||||
}
|
||||
/**
|
||||
* 商城未读消息的数量 及 各订单状态数量
|
||||
* @param integer $returnJson [1代表返回json数据,其他代表返回数组]
|
||||
*/
|
||||
public function getSysMsg($returnJson = 1){
|
||||
$data = model('index')->getSysMsg('msg','order');
|
||||
if($returnJson == 1){
|
||||
exit(jsonReturn("",1,$data));
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 商城未读消息的数量
|
||||
* @param integer $returnJson [1代表返回json数据,其他代表返回数组]
|
||||
*/
|
||||
public function getMsgNum($returnJson = 1){
|
||||
$data = model('index')->getSysMsg('msg');
|
||||
if($returnJson == 1){
|
||||
exit(jsonReturn("",1,$data));
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 商城各订单状态数量
|
||||
* @param integer $returnJson [1代表返回json数据,其他代表返回数组]
|
||||
*/
|
||||
public function getOrderNum($returnJson = 1){
|
||||
$data = model('index')->getSysMsg('','order');
|
||||
if($returnJson == 1){
|
||||
exit(jsonReturn("",1,$data));
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取会员信息
|
||||
* @param integer $returnJson [1代表返回json数据,其他代表返回数组]
|
||||
*/
|
||||
public function getUserInfo($returnJson = 1){
|
||||
$userId = session('WST_USER.userId');
|
||||
$m = new M();
|
||||
$user = $m->getUserInfo($userId,'*');
|
||||
// $where = [];
|
||||
// $where['cr.userId'] = $this->getUserId();
|
||||
// $where['cr.isUse'] = 0;
|
||||
// $now=time();
|
||||
// // $where['ck.begin_time']=array('lt',$now);
|
||||
// $where['ck.end_time']=array('gt',$now);
|
||||
|
||||
// $user['couponNum'] = db('coupon_record')->alias('cr')
|
||||
// ->join('__COUPON_KIND__ ck','cr.couponId=ck.Id','inner')
|
||||
// ->where($where)
|
||||
// ->count();
|
||||
|
||||
if($returnJson == 1){
|
||||
exit(jsonReturn("",1,$user));
|
||||
}else{
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取会员关注商品数和关注商家数
|
||||
* @param integer $returnJson [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getFavoritesNum($returnJson = 1){
|
||||
$m = new Favorites();
|
||||
$data = $m->getFavoritesNum($this->getUserId());
|
||||
$data['shareNum'] = (int)model('UserTrees')->getShareNum(['pid'=>$this->getUserId()]);
|
||||
if($returnJson == 1){
|
||||
exit(jsonReturn("",1,$data));
|
||||
}else{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
public function edit(){
|
||||
$userId = $this->getUserId();
|
||||
$m = new M();
|
||||
$user = $m->getById($userId);
|
||||
exit(jsonReturn('',1,$user));
|
||||
//$this->assign('user', $user);
|
||||
//return $this->fetch('users/edit');
|
||||
}
|
||||
/**
|
||||
* 编辑个人信息
|
||||
*/
|
||||
public function editUserInfo(){
|
||||
$m = new M();
|
||||
return $m->edit();
|
||||
}
|
||||
/**
|
||||
* 账户安全
|
||||
*/
|
||||
public function security(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
$user = $m->getById($userId);
|
||||
$payPwd = $user['payPwd'];
|
||||
$userPhone = $user['userPhone'];
|
||||
$loginPwd = $user['loginPwd'];
|
||||
$user['loginPwd'] = empty($loginPwd)?0:1;
|
||||
$user['payPwd'] = empty($payPwd)?0:1;
|
||||
$user['userPhone'] = empty($userPhone)?0:1;
|
||||
//$this->assign('user', $user);
|
||||
session('Edit_userPhone_Time', null);
|
||||
exit(jsonReturn('',1,$user));
|
||||
//return $this->fetch('users/security/index');
|
||||
}
|
||||
/**
|
||||
* 修改登录密码
|
||||
*/
|
||||
public function editLoginPass(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
$user = $m->getById($userId);
|
||||
$loginPwd = $user['loginPwd'];
|
||||
$user['loginPwd'] = empty($loginPwd)?0:1;
|
||||
exit(jsonReturn('',1,$user));
|
||||
// $this->assign('user', $user);
|
||||
// return $this->fetch('users/security/user_login_pass');
|
||||
}
|
||||
public function editloginPwd(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
return $m->editPass($userId);
|
||||
}
|
||||
/**
|
||||
* 修改支付密码
|
||||
*/
|
||||
public function editPayPass(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
$user = $m->getById($userId);
|
||||
$payPwd = $user['payPwd'];
|
||||
$user['payPwd'] = empty($payPwd)?0:1;
|
||||
exit(jsonReturn('',1,$user));
|
||||
//$this->assign('user', $user);
|
||||
//return $this->fetch('users/security/user_pay_pass');
|
||||
}
|
||||
public function editpayPwd(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
exit(json_encode($m->editPayPass($userId)));
|
||||
}
|
||||
/**
|
||||
* 忘记支付密码
|
||||
*/
|
||||
public function backPayPass(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
$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');
|
||||
$user['backType'] = ($backType==1 && time()<floatval($timeVerify)+10*60)?1:0;
|
||||
exit(jsonReturn('',1,$user));
|
||||
//$this->assign('user', $user);
|
||||
//return $this->fetch('users/security/user_back_paypwd');
|
||||
}
|
||||
/**
|
||||
* 忘记支付密码:发送短信
|
||||
*/
|
||||
public function backpayCode(){
|
||||
$m = new MUsers();
|
||||
$data = $m->getById($this->getUserId());
|
||||
$userPhone = $data['userPhone'];
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
|
||||
$tpl = WSTMsgTemplates('PHONE_FOTGET_PAY');
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['code'=>$phoneVerify]];
|
||||
$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());
|
||||
exit(jsonReturn('短信发送成功!',1));
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 忘记支付密码:验证短信
|
||||
*/
|
||||
public function verifybackPay(){
|
||||
$phoneVerify = input("post.phoneCode");
|
||||
$timeVerify = session('Verify_backPaypwd_Time');
|
||||
if(!session('Verify_backPaypwd_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
|
||||
exit(jsonReturn("校验码已失效,请重新发送!"));
|
||||
}
|
||||
if($phoneVerify==session('Verify_backPaypwd_info.phoneVerify')){
|
||||
session('Type_backPaypwd',1);
|
||||
exit(jsonReturn("验证成功",1));
|
||||
}
|
||||
exit(jsonReturn("校验码不一致,请重新输入!"));
|
||||
}
|
||||
/**
|
||||
* 忘记支付密码:重置密码
|
||||
*/
|
||||
public function resetbackPay(){
|
||||
$m = new M();
|
||||
exit(json_encode($m->resetbackPay()));
|
||||
}
|
||||
/**
|
||||
* 修改手机
|
||||
*/
|
||||
public function editPhone(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
$user = $m->getById($userId);
|
||||
$userPhone = $user['userPhone'];
|
||||
$user['userPhone'] = WSTStrReplace($user['userPhone'],'*',3);
|
||||
$user['phoneType'] = empty($userPhone)?0:1;
|
||||
//$this->assign('user', $user);
|
||||
session('Edit_userPhone_Time', null);
|
||||
exit(jsonReturn('',1,$user));
|
||||
//return $this->fetch('users/security/user_phone');
|
||||
}
|
||||
/**
|
||||
* 绑定手机:发送短信验证码
|
||||
*/
|
||||
public function sendCodeTie(){
|
||||
$userPhone = input("post.userPhone");
|
||||
if(!WSTIsPhone($userPhone)){
|
||||
return jsonReturn("手机号格式不正确!");
|
||||
exit();
|
||||
}
|
||||
$rs = array();
|
||||
$m = new MUsers();
|
||||
$rs = WSTCheckLoginKey($userPhone,$this->getUserId());
|
||||
if($rs["status"]!=1){
|
||||
return jsonReturn("手机号已存在!");
|
||||
exit();
|
||||
}
|
||||
$data = $m->getById($this->getUserId());
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$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,'sendCodeTie',$phoneVerify);
|
||||
}
|
||||
if($rv['status']==1){
|
||||
$USER = '';
|
||||
$USER['userPhone'] = $userPhone;
|
||||
$USER['phoneVerify'] = $phoneVerify;
|
||||
session('Verify_info',$USER);
|
||||
session('Verify_userPhone_Time',time());
|
||||
return jsonReturn('短信发送成功!',1);
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 绑定手机
|
||||
*/
|
||||
public function phoneEdit(){
|
||||
$phoneVerify = input("post.phoneCode");
|
||||
$process = input("post.process");
|
||||
$timeVerify = session('Verify_userPhone_Time');
|
||||
if(!session('Verify_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
|
||||
return jsonReturn("校验码已失效,请重新发送!");
|
||||
exit();
|
||||
}
|
||||
if($phoneVerify==session('Verify_info.phoneVerify')){
|
||||
$m = new M();
|
||||
$rs = $m->editPhone($this->getUserId(),session('Verify_info.userPhone'));
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
return jsonReturn("校验码不一致,请重新输入!");
|
||||
}
|
||||
/**
|
||||
* 修改手机:发送短信验证码
|
||||
*/
|
||||
public function sendCodeEdit(){
|
||||
$m = new MUsers();
|
||||
$data = $m->getById($this->getUserId());
|
||||
$userPhone = $data['userPhone'];
|
||||
$phoneVerify = rand(1000,9999);
|
||||
$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());
|
||||
exit(jsonReturn('短信发送成功!',1));
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 修改手机
|
||||
*/
|
||||
public function phoneEdito(){
|
||||
$phoneVerify = input("post.phoneCode");
|
||||
$timeVerify = session('Verify_userPhone_Time2');
|
||||
if(!session('Verify_info2.phoneVerify') || time()>floatval($timeVerify)+10*60){
|
||||
return jsonReturn("校验码已失效,请重新发送!");
|
||||
exit();
|
||||
}
|
||||
if($phoneVerify==session('Verify_info2.phoneVerify')){
|
||||
session('Edit_userPhone_Time',time());
|
||||
exit(jsonReturn("验证成功",1));
|
||||
}
|
||||
exit(jsonReturn("校验码不一致,请重新输入!",-1));
|
||||
}
|
||||
public function editPhoneo(){
|
||||
$m = new M();
|
||||
$userId = $this->getUserId();
|
||||
$user = $m->getById($userId);
|
||||
$userPhone = $user['userPhone'];
|
||||
$user['userPhone'] = WSTStrReplace($user['userPhone'],'*',3);
|
||||
$timeVerify = session('Edit_userPhone_Time');
|
||||
if(time()>floatval($timeVerify)+15*60){
|
||||
$user['phoneType'] = 1;
|
||||
}else{
|
||||
$user['phoneType'] = 0;
|
||||
}
|
||||
$this->assign('user', $user);
|
||||
return $this->fetch('users/security/user_phone');
|
||||
}
|
||||
/**
|
||||
* 用户退出
|
||||
*/
|
||||
public function logout(){
|
||||
model('users')->appLogOut($this->getUserId());
|
||||
return jsonReturn("",1);
|
||||
}
|
||||
|
||||
/************************************************* 忘记密码 ********************************************************/
|
||||
// 页面过期/失效
|
||||
protected function expire($msg=''){
|
||||
$message = $msg?$msg:'页面已失效!';
|
||||
return jsonReturn($message,-1);
|
||||
//$html = '<h1>'.$message.'</h1><script>setTimeout(function(){location.href="'.url('app/users/index','','',true).'";},1000)</script>';
|
||||
//return $this->display($html);
|
||||
}
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
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 M();
|
||||
$info = $m->getUserInfo($userId,'loginName,userPhone');
|
||||
if($info['userPhone']!='')$info['userPhone'] = WSTStrReplace($info['userPhone'],'*',3);
|
||||
//if($info['userEmail']!='')$info['userEmail'] = WSTStrReplace($info['userEmail'],'*',2,'@');
|
||||
exit(jsonReturn('',1,$info));
|
||||
}else{
|
||||
exit($this->expire());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public function resetPass(){
|
||||
if(!session('findPass')){
|
||||
exit($this->expire());
|
||||
}
|
||||
return $this->fetch('forget_pass3');
|
||||
}
|
||||
public function forgetPasss(){
|
||||
if(!session('findPass')){
|
||||
exit($this->expire());
|
||||
}
|
||||
$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 jsonReturn('验证成功',1);
|
||||
}else{
|
||||
return jsonReturn('校验码错误',-1);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 找回密码
|
||||
*/
|
||||
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 jsonReturn('验证码错误!',-1);
|
||||
// }
|
||||
$loginName = input("post.loginName");
|
||||
$rs = WSTCheckLoginKey($loginName);
|
||||
if($rs["status"]==1){
|
||||
return jsonReturn("用户名不存在!");
|
||||
exit();
|
||||
}
|
||||
$m = new M();
|
||||
$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 jsonReturn("操作成功",1);
|
||||
}else return jsonReturn("用户名不存在!");
|
||||
break;
|
||||
case 2:#第二步,验证方式
|
||||
if (session('findPass.loginName') != null ){
|
||||
if(input("post.modes")==1){
|
||||
if ( session('findPass.userPhone') == null) {
|
||||
return jsonReturn('Error-10002:你没有预留手机号码,请联系客服找回密码!',-1);
|
||||
}
|
||||
$phoneVerify = input("post.Checkcode");
|
||||
if(!$phoneVerify){
|
||||
return jsonReturn('校验码不能为空!',-1);
|
||||
}
|
||||
return $this->checkfindPhone($phoneVerify);
|
||||
}else{
|
||||
if (session('findPass.userEmail')==null) {
|
||||
return jsonReturn('你没有预留邮箱,请通过联系客服找回密码!',-1);
|
||||
}
|
||||
if(!WSTVerifyCheck($code)){
|
||||
return jsonReturn('验证码错误!',-1);
|
||||
}
|
||||
return $this->getfindEmail();
|
||||
}
|
||||
}else exit($this->expire());
|
||||
break;
|
||||
case 3:#第三步,设置新密码
|
||||
$resetPass = session('REST_success');
|
||||
if($resetPass != 1)exit($this->expire());
|
||||
$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 jsonReturn('设置失败');
|
||||
}
|
||||
if ($loginPwd == $repassword) {
|
||||
$m = new M();
|
||||
$rs = $m->resetPass();
|
||||
if($rs['status']==1){
|
||||
exit(json_encode($rs));
|
||||
}else{
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
}else return jsonReturn('两次密码不同!',-1);
|
||||
break;
|
||||
default:
|
||||
exit($this->expire());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 手机验证码获取
|
||||
*/
|
||||
public function getfindPhone(){
|
||||
session('WST_USER',session('findPass.userId'));
|
||||
if(session('findPass.userPhone')==''){
|
||||
return jsonReturn('Error-10001:你没有预留手机号码,请联系客服找回密码!',-1);
|
||||
}
|
||||
$phoneVerify = rand(1000,9999);
|
||||
session('WST_USER',null);
|
||||
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
|
||||
$tpl = WSTMsgTemplates('PHONE_FOTGET');
|
||||
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
|
||||
$params = ['tpl'=>$tpl,'params'=>['code'=>$phoneVerify]];
|
||||
$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);
|
||||
exit(jsonReturn('短信发送成功!',1));
|
||||
}
|
||||
exit(json_encode($rv));
|
||||
}
|
||||
/**
|
||||
* 手机验证码检测
|
||||
* -1 错误,1正确
|
||||
*/
|
||||
public function checkfindPhone($phoneVerify){
|
||||
if(!session('findPhone.phoneVerify') || time()>floatval(session('findPhone.time'))+10*60){
|
||||
return jsonReturn("校验码已失效,请重新发送!");
|
||||
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('app/users/resetPass');
|
||||
exit(json_encode($rs));
|
||||
}
|
||||
return jsonReturn('无效用户',-1);
|
||||
}
|
||||
return jsonReturn('校验码错误!',-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 jsonReturn("发送成功",1);
|
||||
}else{
|
||||
return jsonReturn($sendRs['msg'],-1);
|
||||
}
|
||||
}
|
||||
/** 获取分享信息 mark cheng 20180320*/
|
||||
public function get_share(){
|
||||
$name = session('WST_USER.loginName');
|
||||
$data['url'] = 'http://www.juzi199.com/mobile/users/reg?pName='.$name;
|
||||
$data['bg_share'] = 'upload/sysconfigs/share_3.png';
|
||||
$data['title'] = '新会员注册,即送388元红包,10个ECT,马上注册吧!';
|
||||
$data['desc'] = '新会员注册,即送388元红包,10个ECT,马上注册吧!';
|
||||
exit(jsonReturn('',1,$data));
|
||||
}
|
||||
/*获取用户分享列表*/
|
||||
public function getShareList(){
|
||||
$m = new M();
|
||||
return $m->getShareList();
|
||||
}
|
||||
/**
|
||||
* 获取用户分享信息 *
|
||||
*/
|
||||
public function getShareInfo(){
|
||||
$m = new MUsers();
|
||||
return $m->getShareInfo();
|
||||
}
|
||||
}
|
38
hyhproject/app/controller/Userscores.php
Executable file
38
hyhproject/app/controller/Userscores.php
Executable file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace wstmart\app\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 jsonReturn("", 1,$data);
|
||||
}
|
||||
/**
|
||||
* 签到惠宝
|
||||
*/
|
||||
public function signScore(){
|
||||
$m = new MUserscores();
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$rs = $m->signScore($userId);
|
||||
return $rs;
|
||||
}
|
||||
}
|
66
hyhproject/app/controller/Uservouchers.php
Executable file
66
hyhproject/app/controller/Uservouchers.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Index as M;
|
||||
use wstmart\admin\model\CashDraws as CM;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Uservouchers extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth' => ['except'=>'startgivevouchers,savedaymoney']// 访问这些except下的方法不需要执行前置操作
|
||||
];
|
||||
/**
|
||||
* 保存每日券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function saveDayMoney(){
|
||||
$date = date('Y-m-d');
|
||||
$m = new CM();
|
||||
$m->viewReport($date,1);
|
||||
}
|
||||
/**
|
||||
* 分配券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function startGiveVouchers(){
|
||||
Model('UserVouchers')->startGiveVouchers();
|
||||
}
|
||||
//获取券值
|
||||
public function getVouchers(){
|
||||
$m = Model('common/Table');
|
||||
$vouchersType = (int)input('post.vouchersType');//1产品券2优惠券3旺旺券
|
||||
$isExpected = (int)input('post.isExpected');//是否是预获值
|
||||
$userId = $this->getUserId();
|
||||
$list = [];
|
||||
if(1 == $isExpected){
|
||||
if(1 == $vouchersType || 2 == $vouchersType){
|
||||
$vouchersNames = [1=>'expectedProductNum',2=>'expectedCouponsNum'];
|
||||
$m->setTable('user_vouchers_notice');
|
||||
$list = $m->getSelect(['userId'=>$userId,$vouchersNames[$vouchersType]=>['>=',0.01],'isShow'=>1],$vouchersNames[$vouchersType].' num,remark,moneyType,createTime','id DESC');
|
||||
if(!empty($list['Rows'])){
|
||||
foreach ($list['Rows'] as &$v) {
|
||||
$v['createTime'] = date('Y-m-d H:i:s',$v['createTime']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$m->setTable('shops');
|
||||
$shopIds = $m->getColumn(['status'=>1,'userId'=>$userId],'shopId');
|
||||
// dump($shopIds);
|
||||
if($shopIds){
|
||||
$m->setTable('orders');
|
||||
$list = db('orders')->where(['shopId'=>['in',$shopIds],'orderStatus'=>['BETWEEN','0,1'],'num'=>['>=',0.01],'dataFlag'=>1])->field('SUM((productNum - productHandlingFee - productTaxFee) + (couponsNum - couponsHandlingFee - couponsTaxFee) + wangNum) num ,CONCAT("订单编号:",orderNo,",收入") as remark,dataFlag moneyType,createTime')->group('orderId')->order('orderId DESC')->paginate(input('pageSize/d',10))->toArray();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$m->setTable('shops');
|
||||
$shopIds = $m->getColumn(['status'=>1,'userId'=>$userId],'shopId');
|
||||
$m->setTable('log_moneys');
|
||||
$list = db('log_moneys')->where("((targetType = 0 AND targetId = $userId ) OR (targetType = 1 AND targetId IN (".implode(',',$shopIds) ."))) AND moneyName = $vouchersType AND dataFlag=1")->field('money num,remark,moneyType,createTime')->order('id DESC')->paginate(input('pageSize/d',10))->toArray();
|
||||
//dump(db()->_sql());
|
||||
// $list = $m->getSelect(['targetType'=>0,'targetId'=>$userId,'moneyName'=>$vouchersType,'dataFlag'=>1],'money num,remark,moneyType,createTime','id DESC');
|
||||
}
|
||||
exit(jsonReturn('',1,$list));
|
||||
}
|
||||
}
|
48
hyhproject/app/controller/Wallets.php
Executable file
48
hyhproject/app/controller/Wallets.php
Executable file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\common\model\Orders as OM;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 源宝控制器
|
||||
*/
|
||||
class Wallets extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth'
|
||||
];
|
||||
/**
|
||||
* 跳去支付页面
|
||||
*/
|
||||
public function payment(){
|
||||
$data = [];
|
||||
$data['orderNo'] = input('orderNo');
|
||||
$data['isBatch'] = (int)input('isBatch');
|
||||
$data['userId'] = (int)session('WST_USER.userId');
|
||||
$this->assign('data',$data);
|
||||
$m = new OM();
|
||||
$rs = $m->getOrderPayInfo($data);//获取订单金额以及用户钱包金额
|
||||
|
||||
$pay['list'] = $m->getByUnique();// 根据订单唯一流水获取订单信息
|
||||
|
||||
if(empty($rs)){//已支付或者找不到此订单
|
||||
exit(jsonReturn('读取失败',-1));
|
||||
}else{
|
||||
$pay['needPay'] = $rs['needPay'];//需付款
|
||||
//获取用户钱包
|
||||
$user = model('users')->getFieldsById($data['userId'],'userMoney,payPwd');
|
||||
$pay['userMoney'] = $user['userMoney'];
|
||||
$payPwd = $user['payPwd'];
|
||||
$payPwd = empty($payPwd)?0:1;
|
||||
$pay['payPwd'] = $payPwd;//1有密码0没设置密码
|
||||
}
|
||||
exit(jsonReturn('',1,$pay));
|
||||
|
||||
}
|
||||
/**
|
||||
* 钱包支付
|
||||
*/
|
||||
public function payByWallet(){
|
||||
$m = new OM();
|
||||
exit(json_encode($m->payByWallet()));
|
||||
}
|
||||
}
|
185
hyhproject/app/controller/Weixinpays.php
Executable file
185
hyhproject/app/controller/Weixinpays.php
Executable file
@ -0,0 +1,185 @@
|
||||
<?php
|
||||
namespace wstmart\app\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\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.WxJsApiPay');
|
||||
|
||||
$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("app/weixinpays/notify","",true,true);
|
||||
$this->wxpayConfig['returnurl'] = url("app/orders/index","",true,true);
|
||||
$this->wxpayConfig['curl_timeout'] = 30;
|
||||
|
||||
// 初始化WxPayConf
|
||||
new \WxPayConf($this->wxpayConfig);
|
||||
}
|
||||
|
||||
|
||||
public function toWeixinPay(){
|
||||
$data = [];
|
||||
$payObj = input("payObj/s");
|
||||
if($payObj=="recharge"){
|
||||
$cm = new CM();
|
||||
$itemId = (int)input("itemId/d");
|
||||
$targetType = (int)input("targetType/d");
|
||||
$targetId = (int)session('WST_USER.userId');
|
||||
if($targetType==1){//商家
|
||||
$targetId = (int)session('WST_USER.shopId');
|
||||
}
|
||||
$needPay = 0;
|
||||
if($itemId>0){
|
||||
$item = $cm->getItemMoney($itemId);
|
||||
$needPay = isSet($item["chargeMoney"])?$item["chargeMoney"]:0;
|
||||
}else{
|
||||
$needPay = (int)input("needPay/d");
|
||||
}
|
||||
$out_trade_no = WSTOrderNo();
|
||||
$body = "钱包充值";
|
||||
$data["status"] = $needPay>0?1:-1;
|
||||
$attach = $payObj."@".$targetId."@".$targetType."@".$needPay."@".$itemId;
|
||||
$returnurl = url("app/logmoneys/usermoneys","",true,true);
|
||||
}else{
|
||||
|
||||
$data['orderNo'] = input('orderNo');
|
||||
$data['isBatch'] = (int)input('isBatch');
|
||||
$data['userId'] = (int)session('WST_USER.userId');
|
||||
$m = new OM();
|
||||
$rs = $m->getOrderPayInfo($data);
|
||||
if(empty($rs)){
|
||||
$this->assign('type','');
|
||||
return $this->fetch("users/orders/orders_list");
|
||||
}else{
|
||||
$pkey = base64_decode(input("pkey"));
|
||||
$extras = explode ( "@",$pkey);
|
||||
|
||||
$m = new OM();
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$obj["userId"] = $userId;
|
||||
$obj["orderNo"] = input("orderNo");
|
||||
$obj["isBatch"] = (int)input("isBatch");
|
||||
|
||||
$rs = $m->getByUnique();
|
||||
$this->assign('rs',$rs);
|
||||
$body = "支付订单";
|
||||
$order = $m->getPayOrders($obj);
|
||||
$needPay = $order["needPay"];
|
||||
$payRand = $order["payRand"];
|
||||
$out_trade_no = $obj["orderNo"]."a1".$payRand;
|
||||
$attach = $userId."@".$obj["orderNo"]."@".$obj["isBatch"];
|
||||
$returnurl = url("app/orders/index","",true,true);
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化WxPayConf
|
||||
new \WxPayConf ( $this->wxpayConfig );
|
||||
//使用统一支付接口
|
||||
$notify_url = $this->wxpayConfig ['notifyurl'];
|
||||
$unifiedOrder = new \UnifiedOrder();
|
||||
$unifiedOrder->setParameter("out_trade_no",$out_trade_no);//商户订单号
|
||||
$unifiedOrder->setParameter("notify_url",$notify_url);//通知地址
|
||||
$unifiedOrder->setParameter("trade_type","MWEB");//交易类型
|
||||
$unifiedOrder->setParameter("attach",$attach);//扩展参数
|
||||
$unifiedOrder->setParameter("body",$body);//商品描述
|
||||
$needPay = WSTBCMoney($needPay,0,2);
|
||||
$unifiedOrder->setParameter("total_fee", $needPay * 100);//总金额
|
||||
|
||||
$wap_name = WSTConf('CONF.mallName');
|
||||
$unifiedOrder->setParameter("scene_info", "{'h5_info': {'type':'Wap','wap_url': '".$notify_url."','wap_name': '".$wap_name."'}}");//总金额
|
||||
|
||||
$this->assign('needPay',$needPay);
|
||||
$this->assign('returnUrl',$returnurl );
|
||||
$this->assign('payObj',$payObj);
|
||||
$wxResult = $unifiedOrder->getResult();
|
||||
$this->assign('mweb_url',$wxResult['mweb_url']."&redirect_url".urlencode($returnurl));
|
||||
return $this->fetch('users/orders/orders_wxpay');
|
||||
}
|
||||
|
||||
|
||||
public function notify() {
|
||||
// 使用通用通知接口
|
||||
$notify = new \Notify();
|
||||
// 存储微信的回调
|
||||
$xml = file_get_contents("php://input");
|
||||
$notify->saveData ( $xml );
|
||||
if ($notify->checkSign () == FALSE) {
|
||||
$notify->setReturnParameter ( "return_code", "FAIL" ); // 返回状态码
|
||||
$notify->setReturnParameter ( "return_msg", "签名失败" ); // 返回信息
|
||||
} else {
|
||||
$notify->setReturnParameter ( "return_code", "SUCCESS" ); // 设置返回码
|
||||
}
|
||||
$returnXml = $notify->returnXml ();
|
||||
if ($notify->checkSign () == TRUE) {
|
||||
if ($notify->data ["return_code"] == "FAIL") {
|
||||
// 此处应该更新一下订单状态,商户自行增删操作
|
||||
} elseif ($notify->data ["result_code"] == "FAIL") {
|
||||
// 此处应该更新一下订单状态,商户自行增删操作
|
||||
} else {
|
||||
$order = $notify->getData ();
|
||||
$rs = $this->process($order);
|
||||
if($rs["status"]==1){
|
||||
echo "SUCCESS";
|
||||
}else{
|
||||
echo "FAIL";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//订单处理
|
||||
private function process($order) {
|
||||
|
||||
$obj = array();
|
||||
$obj["trade_no"] = $order['transaction_id'];
|
||||
|
||||
$obj["total_fee"] = (float)$order["total_fee"]/100;
|
||||
$extras = explode ( "@", $order ["attach"] );
|
||||
if($extras[0]=="recharge"){//充值
|
||||
$targetId = (int)$extras [1];
|
||||
$targetType = (int)$extras [2];
|
||||
$itemId = (int)$extras [4];
|
||||
|
||||
$obj["out_trade_no"] = $order['out_trade_no'];
|
||||
$obj["targetId"] = $targetId;
|
||||
$obj["targetType"] = $targetType;
|
||||
$obj["itemId"] = $itemId;
|
||||
$obj["payFrom"] = 'weixinpays';
|
||||
// 支付成功业务逻辑
|
||||
$m = new LM();
|
||||
$rs = $m->complateRecharge ( $obj );
|
||||
}else{
|
||||
$obj["userId"] = $extras[0];
|
||||
$obj["out_trade_no"] = $extras[1];
|
||||
$obj["isBatch"] = $extras[2];
|
||||
$obj["payFrom"] = "weixinpays";
|
||||
// 支付成功业务逻辑
|
||||
$m = new OM();
|
||||
$rs = $m->complatePay ( $obj );
|
||||
}
|
||||
|
||||
return $rs;
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user