You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
BIN
hyhproject/app/.DS_Store
vendored
Executable file
BIN
hyhproject/app/.DS_Store
vendored
Executable file
Binary file not shown.
BIN
hyhproject/app/._.DS_Store
Executable file
BIN
hyhproject/app/._.DS_Store
Executable file
Binary file not shown.
21
hyhproject/app/common/function.php
Executable file
21
hyhproject/app/common/function.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
*/
|
||||
/**
|
||||
* 获取购物车数量
|
||||
*/
|
||||
function WSTCartNum(){
|
||||
$userId = session('WST_USER.userId');
|
||||
$cartNum = Db::name('carts')->where(['userId'=>$userId])->field('cartId')->select();
|
||||
$count = count($cartNum);
|
||||
return $count;
|
||||
}
|
||||
function appLogOut(){
|
||||
Db::name('users')->where(['userId'=>1])->setField('token','');
|
||||
session('WST_USER',null);
|
||||
//setcookie("loginPwd", null);
|
||||
session('WST_MO_WlADDRESS',null);
|
||||
}
|
||||
|
14
hyhproject/app/conf/config.php
Executable file
14
hyhproject/app/conf/config.php
Executable file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
|
||||
];
|
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
BIN
hyhproject/app/model/.DS_Store
vendored
Executable file
BIN
hyhproject/app/model/.DS_Store
vendored
Executable file
Binary file not shown.
BIN
hyhproject/app/model/._.DS_Store
Executable file
BIN
hyhproject/app/model/._.DS_Store
Executable file
Binary file not shown.
BIN
hyhproject/app/model/._Goods.php
Executable file
BIN
hyhproject/app/model/._Goods.php
Executable file
Binary file not shown.
BIN
hyhproject/app/model/._Shops.php
Executable file
BIN
hyhproject/app/model/._Shops.php
Executable file
Binary file not shown.
224
hyhproject/app/model/AppPort.php
Executable file
224
hyhproject/app/model/AppPort.php
Executable file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 文章类
|
||||
*/
|
||||
class AppPort extends Model{
|
||||
/*
|
||||
* APP首页轮播图
|
||||
* */
|
||||
public function appBanner(){
|
||||
$result=listAds('app_new_top_banner',8,0);
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* app新版桔子头条
|
||||
*/
|
||||
public function appNews(){
|
||||
$catId=8;
|
||||
$where = array();
|
||||
$where['isShow'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$catIds=db('article_cats')->where(['parentId'=>$catId,'dataFlag'=>1])->column('catId');
|
||||
$where['catId']=array('in',$catIds);
|
||||
$result = Db::name('articles')->where($where)->field('articleId,articleTitle,catId')->select();
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* app新版桔子头条分类接口
|
||||
*/
|
||||
public function appNewsClass(){
|
||||
$catId=(int)input('catId/d');
|
||||
$where = array();
|
||||
$where['isShow'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$id=db('article_cats')->where(['catId'=>$catId,'dataFlag'=>1])->value('parentId');
|
||||
$where['parentId']=$id;
|
||||
$result = Db::name('article_cats')->where($where)->select();
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* app新版桔子头条
|
||||
*/
|
||||
public function appNewsLists(){
|
||||
$catId=(int)input('catId/d');
|
||||
$articleId=(int)input('articleId');
|
||||
$where = array();
|
||||
$where['isShow'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$id=db('article_cats')->where(['catId'=>$catId,'dataFlag'=>1])->value('parentId');
|
||||
$where['parentId']=$id;
|
||||
$result = Db::name('article_cats')->where($where)->select();
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* app新版桔子头条详情页借口
|
||||
*/
|
||||
public function appNewsDetail(){
|
||||
$articleId=(int)input('articleId');
|
||||
$where = array();
|
||||
$where['isShow'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['articleId']=$articleId;
|
||||
$result = Db::name('articles')->where($where)->select();
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
* app新版秒杀接口
|
||||
* */
|
||||
public function appSecKill(){
|
||||
$now=time();
|
||||
$where=[];
|
||||
$where['startTime']=array('elt',$now);
|
||||
$where['endTime']=array('egt',$now);
|
||||
$result=Db::name('hyhsale_goods')->alias('gu')
|
||||
->join('__GOODS__ g','gu.goodsId=g.goodsId','inner')
|
||||
->where('g.dataFlag=1 and g.isSale=1 and g.goodsStatus=1 and gu.dataFlag=1 and gu.hyhsaleStatus=1 and gu.isSelf=0')
|
||||
->where($where)
|
||||
->field('gu.goodsId,g.marketPrice,gu.goodsPrice,gu.totalNum,gu.startTime,gu.endTime,g.goodsName,g.goodsImg,gu.specsId')
|
||||
->select();
|
||||
foreach($result as &$v){
|
||||
$v['goodsImg']=WSTImg($v['goodsImg'],3);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
* app新版ect专区/活动层接口
|
||||
* */
|
||||
public function appEctAct(){
|
||||
$result['ect']=listAds('app_new_ect_left',1,0);
|
||||
$result['act']=listAds('app_new_act_photo',1,0);
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
* app新版品牌热卖接口
|
||||
* */
|
||||
public function appBrands(){
|
||||
$result['brands']=listAds('app_new_page_brand',1,0);
|
||||
$result['brandsList']=db('brands b')
|
||||
->join('hyhbrands_rec hr','b.brandId=hr.brandId')
|
||||
->whereNotIn('hr.isSelf',1)
|
||||
->field('b.brandId,brandName,brandImg,shopId,findOrder')
|
||||
->where(['dataFlag'=>1])->limit(6)->order('findOrder desc')->select();
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
* app新版居家好帮手广告位接口
|
||||
* */
|
||||
public function appJadvertis(){
|
||||
//居家好帮手左上位置
|
||||
$row['left']=listAds('app_new_jujia_lt',2,0);
|
||||
$row['right']=listAds('app_new_jujia_rt',2,0);
|
||||
$result['zxz']=listAds('app_new_jujia_lul',1,0);
|
||||
$result['zxy']=listAds('app_new_jujia_lur',1,0);
|
||||
$result['yxz']=listAds('app_new_jujia_rul',1,0);
|
||||
$result['yxy']=listAds('app_new_jujia_rur',1,0);
|
||||
$row['under']= array_merge($result['zxz'],$result['zxy'],$result['yxz'],$result['yxy']);
|
||||
return $row;
|
||||
}
|
||||
/*
|
||||
* app新版潮流先锋广告位接口
|
||||
* */
|
||||
public function appCadvertis(){
|
||||
//潮流先锋左上位置
|
||||
$row['left']=listAds('app_new_chao_lt',2,0);
|
||||
//潮流先锋左下左位置
|
||||
$result['zxz']=listAds('app_new_chao_lul',1,0);
|
||||
//潮流先锋左下右位置
|
||||
$result['zxy']=listAds('app_new_chao_lur',1,0);
|
||||
//潮流先锋右上位置
|
||||
$row['right']=listAds('app_new_chao_rt',2,0);
|
||||
//潮流先锋右下左位置
|
||||
$result['yxz']=listAds('app_new_chao_rul',1,0);
|
||||
//潮流先锋右下右位置
|
||||
$result['yxy']=listAds('app_new_chao_rur',1,0);
|
||||
$row['under']= array_merge($result['zxz'],$result['zxy'],$result['yxz'],$result['yxy']);
|
||||
return $row;
|
||||
}
|
||||
/*
|
||||
* app新版食品超市广告位接口
|
||||
* */
|
||||
public function appSadvertis(){
|
||||
//食品超市左上位置
|
||||
$row['left']=listAds('app_new_shi_lt',2,0);
|
||||
//食品超市左下左位置
|
||||
$result['zxz']=listAds('app_new_shi_lul',1,0);
|
||||
//食品超市左下右位置
|
||||
$result['zxy']=listAds('app_new_shi_lur',1,0);
|
||||
//食品超市右上位置
|
||||
$row['right']=listAds('app_new_shi_rt',2,0);
|
||||
//食品超市右下左位置
|
||||
$result['yxz']=listAds('app_new_shi_rul',1,0);
|
||||
//食品超市右下右位置
|
||||
$result['yxy']=listAds('app_new_shi_rur',1,0);
|
||||
$row['under']= array_merge($result['zxz'],$result['zxy'],$result['yxz'],$result['yxy']);
|
||||
return $row;
|
||||
}
|
||||
/*
|
||||
* app新版家电馆广告位接口
|
||||
* */
|
||||
public function appDadvertis(){
|
||||
//家电馆左上位置
|
||||
$row['left']=listAds('app_new_dian_lt',2,0);
|
||||
//家电馆左下左位置
|
||||
$result['zxz']=listAds('app_new_dian_lul',1,0);
|
||||
//家电馆左下右位置
|
||||
$result['zxy']=listAds('app_new_dian_lur',1,0);
|
||||
//家电馆右上位置
|
||||
$row['right']=listAds('app_new_dian_rt',2,0);
|
||||
//家电馆右下左位置
|
||||
$result['yxz']=listAds('app_new_dian_rul',1,0);
|
||||
//家电馆右下右位置
|
||||
$result['yxy']=listAds('app_new_dian_rur',1,0);
|
||||
$row['under']= array_merge($result['zxz'],$result['zxy'],$result['yxz'],$result['yxy']);
|
||||
return $row;
|
||||
}
|
||||
/*
|
||||
* app为你推荐接口
|
||||
* */
|
||||
public function recommend(){
|
||||
$userId=session('WST_USER.userId');
|
||||
$page = (int)input('post.page/d');
|
||||
$cacheData = cache('APP_CATS_RECOMMEND_'.$page.'_'.$userId);
|
||||
if($cacheData)return $cacheData;
|
||||
$childId=[];
|
||||
$catId=[];
|
||||
$goodsCat=[];
|
||||
$goods_ids=db('page_view')->where('userId',$userId)->field('count(goodsId)num,goodsId')->group('goodsId')->order('num desc')->limit('10')->select();
|
||||
foreach($goods_ids as $key=>$value){
|
||||
$childId[]=$value['goodsId'];
|
||||
}
|
||||
if(!$userId ||count($childId)<4){
|
||||
$goods_ids=db('page_view')->field('count(goodsId)num,goodsId')->group('goodsId')->order('num desc')->limit('10')->select();
|
||||
foreach($goods_ids as $key=>$value){
|
||||
$childId[]=$value['goodsId'];
|
||||
}
|
||||
}
|
||||
|
||||
$catIds=db('goods')->whereIn('goodsId',$childId)->field('goodsCatIdPath')->select();
|
||||
foreach($catIds as $key=>$value){
|
||||
$cat=explode("_",$value['goodsCatIdPath']);
|
||||
//$goodsCat=current($cat);
|
||||
$goodsCatId=next($cat);
|
||||
$cat=db('goods_cats')->where(['catId'=>$goodsCatId,'dataFlag'=>1])->value('catId');
|
||||
$catId[]=$cat;
|
||||
}
|
||||
$catId=array_unique(array_filter($catId));
|
||||
//dump($catId);
|
||||
$childId=db('goods_cats')->whereIn('parentId',$catId)->field('catId')->select();
|
||||
//dump($childId);
|
||||
foreach($childId as $k=>$v){
|
||||
foreach($v as $kk=>$vv){
|
||||
$goodsCat[]=$vv;
|
||||
}
|
||||
}
|
||||
$goods=db('goods')->whereIn('goodsCatId',$goodsCat)->where('dataFlag=1 AND isSale=1 AND goodsStatus=1')
|
||||
->field('goodsId,goodsName,goodsImg,shopId,marketPrice,shopPrice')
|
||||
->paginate(input('pagesize/d'))->toArray();
|
||||
cache('APP_CATS_RECOMMEND_'.$page.'_'.$userId,$goods,3600);
|
||||
return $goods;
|
||||
}
|
||||
}
|
61
hyhproject/app/model/Articles.php
Executable file
61
hyhproject/app/model/Articles.php
Executable file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 文章类
|
||||
*/
|
||||
class Articles extends Base{
|
||||
/**
|
||||
* 获取资讯中心的子集分类id
|
||||
*/
|
||||
public function getChildIds(){
|
||||
$ids = cache('NEW_IDS');
|
||||
if(!$ids){
|
||||
$data = Db::name('article_cats')->cache(true)->select();
|
||||
foreach($data as $k=>$v){
|
||||
if($v['parentId']!=7 && $v['catId']!=7 && $v['parentId']!=0 ){
|
||||
$ids[] = $v['catId'];
|
||||
}
|
||||
}
|
||||
cache('NEW_IDS',$ids);
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取咨询中中心所有文章
|
||||
*/
|
||||
public function getArticles(){
|
||||
// 获取咨询中心下的所有分类id
|
||||
$ids = $this->getChildIds();
|
||||
$rs = $this->alias('a')
|
||||
->field('a.*')
|
||||
->join('__ARTICLE_CATS__ ac','a.catId=ac.catId','inner')
|
||||
->where(['a.catId'=>['in',$ids],
|
||||
'a.isShow'=>1,
|
||||
'a.dataFlag'=>1,
|
||||
'ac.dataFlag'=>1,
|
||||
'ac.isShow'=>1,
|
||||
'ac.catType'=>0,
|
||||
])
|
||||
->order('createTime desc')
|
||||
->paginate((int)input('pagesize'));
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取资讯文章
|
||||
*/
|
||||
public function getNewsById(){
|
||||
$id = (int)input('id');
|
||||
WSTArticleVisitorNum($id);// 统计文章访问量
|
||||
return $this->alias('a')
|
||||
->field('a.*')
|
||||
->join('__ARTICLE_CATS__ ac','a.catId=ac.catId','inner')
|
||||
->where('ac.catType=0 and a.dataFlag=1 and a.isShow=1')
|
||||
->cache(true)
|
||||
->find($id);
|
||||
}
|
||||
}
|
9
hyhproject/app/model/Base.php
Executable file
9
hyhproject/app/model/Base.php
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Base as CBase;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 基础模型器
|
||||
*/
|
||||
|
||||
class Base extends CBase {}
|
303
hyhproject/app/model/Carts.php
Executable file
303
hyhproject/app/model/Carts.php
Executable file
@ -0,0 +1,303 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Carts as CCarts;
|
||||
use think\Db;
|
||||
/**
|
||||
* 购物类
|
||||
*/
|
||||
class Carts extends CCarts{
|
||||
/**
|
||||
* 购买保存下参数
|
||||
* @param integer $goodsId [description]
|
||||
* @param integer $goodsSpecId [description]
|
||||
* @param integer $buyNum [description]
|
||||
* @param integer $uId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function buy($goodsId=0, $goodsSpecId=0, $buyNum =0, $uId=0){
|
||||
|
||||
$userId = ($uId==0)?(int)session('WST_USER.userId'):$uId;
|
||||
if(!$userId){
|
||||
return WSTReturn('购买失败,请先登录',-999);
|
||||
}
|
||||
$goodsId = ($goodsId==0)?input('goodsId/d'):$goodsId;
|
||||
if(!$goodsId){
|
||||
exit(jsonReturn('请输入参数值!',-1));
|
||||
}
|
||||
$goodsSpecId = ($goodsSpecId==0)?input('goodsSpecId/d',0):$goodsSpecId;
|
||||
$buyNum = ($buyNum==0)?input('buyNum/d',1):$buyNum;
|
||||
$goodsType = (int)input('goodsType/d',1); //1逛商都2助微吧
|
||||
$buyNum = ($buyNum>0)?$buyNum:1;
|
||||
//验证传过来的商品是否合法
|
||||
$chk = $this->checkGoodsSaleSpec($goodsId,$goodsSpecId);
|
||||
if($chk['status']==-1)return $chk;
|
||||
$goodsSpecId = $chk['data']['goodsSpecId'];
|
||||
//检测库存是否足够
|
||||
if($chk['data']['stock']<$buyNum){
|
||||
return WSTReturn("购买失败,商品库存不足", -1);
|
||||
}
|
||||
$carts = [];
|
||||
$carts['goodsId'] = $goodsId;
|
||||
$carts['goodsSpecId'] = $goodsSpecId;
|
||||
$carts['buyNum'] = $buyNum;
|
||||
$carts['goodsType'] = $goodsType;
|
||||
session('HYH_CARTS',$carts);
|
||||
return WSTReturn("添加成功", 1);
|
||||
}
|
||||
/**
|
||||
* 现在购买
|
||||
* isSettlement 是结算页面
|
||||
* uId 会员ID,默认为当前ID
|
||||
* userAddress 会员地址
|
||||
*/
|
||||
public function buyNow($areaId2=0, $uId=0){
|
||||
$hyhCarts = session('HYH_CARTS');
|
||||
$goodsId = $hyhCarts['goodsId'];
|
||||
$goodsSpecId =$hyhCarts['goodsSpecId'];
|
||||
$buyNum = $hyhCarts['buyNum'];
|
||||
$areaId2 = ($areaId2==0)?input('areaId2/d'):$areaId2;
|
||||
$userId = ($uId==0)?(int)session('WST_USER.userId'):$uId;
|
||||
if(!$goodsId){
|
||||
exit(jsonReturn('请勿重新下单!',-2));
|
||||
}
|
||||
if(!$userId){
|
||||
exit(jsonReturn('请重新登录下单!',-999));
|
||||
}
|
||||
$where = [];
|
||||
$where['g.goodsId'] = $goodsId;
|
||||
$where['g.dataFlag'] = 1;
|
||||
$where['g.goodsStatus'] = 1;
|
||||
$where['g.isSale'] = 1;
|
||||
$where['s.dataFlag'] = 1;
|
||||
$where['s.shopStatus'] = 1;
|
||||
$where['s.status'] = 1;
|
||||
if($goodsSpecId){
|
||||
$where['gs.id'] = $goodsSpecId;
|
||||
}
|
||||
//获取商品和商店信息
|
||||
$rs = Db::name('goods g')
|
||||
->join('__SHOPS__ s','s.shopId=g.shopId','left')
|
||||
->join('__GOODS_SPECS__ gs','g.goodsId=gs.goodsId','left')
|
||||
->where($where)
|
||||
->field('s.userId,s.shopId,s.shopName,s.userId shopUserId,s.shopLevel,g.goodsId,g.goodsName,g.shopPrice,g.goodsStock,g.isSpec,g.marketPrice,gs.specPrice,gs.specStock,g.goodsImg,gs.specIds,g.goodsCatId,g.freight,g.isFreeShipping,gs.initNum,gs.whslePrice')
|
||||
->find();
|
||||
if(!$rs){
|
||||
exit(jsonReturn('商品读取失败',-1));
|
||||
}
|
||||
|
||||
$cartsInfo[$rs['shopId']]['isFreeShipping'] = (bool)$rs['isFreeShipping'];
|
||||
$cartsInfo[$rs['shopId']]['promotion'] = [];
|
||||
$cartsInfo[$rs['shopId']]['promotionMoney'] = 0;
|
||||
$cartsInfo[$rs['shopId']]['shopId'] = $rs['shopId'];
|
||||
$cartsInfo[$rs['shopId']]['shopName'] = $rs['shopName'];
|
||||
$cartsInfo[$rs['shopId']]['userId'] = $rs['userId'];
|
||||
if($rs['isSpec']==1){
|
||||
$rs['shopPrice'] = $rs['specPrice'];
|
||||
$rs['goodsStock'] = $rs['specStock'];
|
||||
}else{
|
||||
$rs['initNum'] = 0;
|
||||
$rs['whslePrice'] = 0;
|
||||
}
|
||||
$hyhCarts['goodsType'] = (int) $hyhCarts['goodsType'];
|
||||
if(2 == $hyhCarts['goodsType']){//助微吧购物判断店主等级
|
||||
$tm = Model('common/Table');
|
||||
$tm->setTable('shops');
|
||||
//换算为3级循环等级
|
||||
if(0 == $rs['shopLevel']){
|
||||
$maxSaleMoney = dataConf('helpLevel0MaxSaleMoney');
|
||||
}else{
|
||||
//$nowLevel = $rs['shopLevel'] % 3;
|
||||
$tm->setTable('users');
|
||||
//最大可销售金额
|
||||
$maxSaleMoney = $tm->getField(['userId'=>$rs['shopUserId']],'helpMaxSaleMoney');
|
||||
}
|
||||
|
||||
$tm->setTable('shops');
|
||||
//当前销售值
|
||||
$nowSaleMoney = $tm->getSum(['userId'=>$rs['shopUserId']],'helpSaleMoney');
|
||||
if(($nowSaleMoney+$rs['shopPrice']) > $maxSaleMoney ){
|
||||
exit(jsonReturn('当前助微吧商户可销售额不足!',-1));
|
||||
}
|
||||
|
||||
}
|
||||
$cartsInfo[$rs['shopId']]['goodsMoney'] = $rs['shopPrice'] * $buyNum;
|
||||
//判断能否购买,预设allowBuy值为10,为将来的各种情况预留10个情况值,从0到9
|
||||
$rs['allowBuy'] = 10;
|
||||
if($rs['goodsStock']<=0){
|
||||
//$rs['allowBuy'] = 0;//库存不足
|
||||
exit(jsonReturn('库存不足',-1));
|
||||
}else if($rs['goodsStock']<$buyNum){
|
||||
//$rs['allowBuy'] = 1;//库存比购买数小
|
||||
$buyNum = $rs['goodsStock'];
|
||||
}
|
||||
|
||||
|
||||
$rs['specNames'] = [];
|
||||
//加载规格值
|
||||
if($goodsSpecId>0){
|
||||
$specs = DB::name('spec_items')->alias('s')->join('__SPEC_CATS__ sc','s.catId=sc.catId','left')
|
||||
->where(['s.goodsId'=>$rs['goodsId'],'s.dataFlag'=>1])->field('catName,itemId,itemName')->select();
|
||||
if(count($specs)>0){
|
||||
$specMap = [];
|
||||
foreach ($specs as $key =>$v){
|
||||
$specMap[$v['itemId']] = $v;
|
||||
}
|
||||
$strName = [];
|
||||
if($rs['specIds']!=''){
|
||||
$str = explode(':',$rs['specIds']);
|
||||
foreach ($str as $vv){
|
||||
if(isset($specMap[$vv]))$strName[] = $specMap[$vv];
|
||||
}
|
||||
$rs['specNames'] = $strName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$cartsInfo[$rs['shopId']]['list']['0'] = $rs;
|
||||
$cartsInfo[$rs['shopId']]['list']['0']['promotion'] = [];
|
||||
$cartsInfo[$rs['shopId']]['list']['0']['goodsSpecId'] = $goodsSpecId;
|
||||
$cartsInfo[$rs['shopId']]['list']['0']['cartNum'] = $buyNum;
|
||||
$cartsInfo[$rs['shopId']]['list']['0']['cartId'] = $goodsSpecId;
|
||||
$goodsTotalMoney = $rs['shopPrice'] * $buyNum ;
|
||||
$goodsTotalNum = 1;
|
||||
$cartData = ['carts'=>$cartsInfo,'goodsTotalMoney'=>$goodsTotalMoney,'goodsTotalNum'=>$goodsTotalNum,'promotionMoney'=>0];
|
||||
//秒杀活动监听
|
||||
hook("beforeSettlement",["carts"=>&$cartData]);
|
||||
$allShippingMoney = 0;
|
||||
if(empty($cartData['carts']['is_seckilling'])){
|
||||
//批发插件 mart hsf 20171116
|
||||
hook("mobileControllerCartsSettlement",["carts"=>&$cartData]);
|
||||
//店铺优惠活动监听
|
||||
hook('afterQueryCarts',["carts"=>&$cartData,'isSettlement'=>true,'isVirtual'=>false,'uId'=>$userId]);
|
||||
//ect整合相关优惠还有判断不能和在线支付商品一块
|
||||
hook("ectIntegration",["carts"=>&$cartData,'isSettlement'=>true,'uId'=>$userId]);
|
||||
//11.11会场商品结算钩子
|
||||
hook("orderCatsDoubleEleven",["carts"=>&$cartData,'isSettlement'=>true,'uId'=>$userId]);
|
||||
|
||||
}
|
||||
//添加运费计算
|
||||
if($rs['isFreeShipping']){
|
||||
$cartData['carts'][$rs['shopId']]["shippingMoney"] = 0;
|
||||
}else{
|
||||
$cartData['carts'][$rs['shopId']]["shippingMoney"] = $rs['freight'];
|
||||
// if($areaId2){
|
||||
// $cartData['carts'][$rs['shopId']]["shippingMoney"] = WSTOrderFreight($rs['shopId'],$areaId2);
|
||||
// }else{
|
||||
// $cartData['carts'][$rs['shopId']]["shippingMoney"] = WSTOrderFreight($rs['shopId'],-1);
|
||||
// }
|
||||
$allShippingMoney += $cartData['carts'][$rs['shopId']]["shippingMoney"];
|
||||
}
|
||||
if($allShippingMoney){
|
||||
$cartData['goodsTotalMoney'] += $allShippingMoney;
|
||||
}
|
||||
$cartData['allShippingMoney'] = $allShippingMoney;//添加总运费
|
||||
$cartData['goodsType'] = $hyhCarts['goodsType'];
|
||||
return $cartData;
|
||||
}
|
||||
/**
|
||||
* 计算订单金额
|
||||
*/
|
||||
public function getMoney($areaId2=0, $uId=0){
|
||||
$data = ['shops'=>[],'totalMoney'=>0,'totalGoodsMoney'=>0];
|
||||
$userId = $uId==0?(int)session('WST_USER.userId'):$uId;
|
||||
$areaId = input('post.areaId2/d',-1);
|
||||
//计算各店铺运费及金额
|
||||
$deliverType = (int)input('deliverType');//0是快递,1是自提,自提的不要运费,先取消
|
||||
$carts = $this->buyNow($areaId,$userId);
|
||||
$shopFreight = 0;
|
||||
$maxScoreMoney = 0;//初始化最大可用惠宝数 mark hsf 20171117
|
||||
$total_promotion_money = 0;//初始化合计优惠 mark hsf 20170303
|
||||
$data['maxScoreMoneySum'] = 0;
|
||||
foreach ($carts['carts'] as &$v){//优化一下循环效率 mark hsf 20171118
|
||||
|
||||
// if($v['isFreeShipping']){
|
||||
// $data['shops'][$v['shopId']]['freight'] = 0;
|
||||
// }else{
|
||||
// $shopFreight = ($deliverType==1)?0:WSTOrderFreight($v['shopId'],$areaId);
|
||||
// $data['shops'][$v['shopId']]['freight'] = $shopFreight;
|
||||
// }
|
||||
if($v['isFreeShipping']){
|
||||
$shopFreight = 0;
|
||||
}else{
|
||||
if($deliverType == 0){
|
||||
$shopFreight = $v['shippingMoney'];
|
||||
}
|
||||
}
|
||||
|
||||
$data['shops'][$v['shopId']]['freight'] = $shopFreight;
|
||||
$data['shops'][$v['shopId']]['oldGoodsMoney'] = $v['goodsMoney'];
|
||||
$data['shops'][$v['shopId']]['goodsMoney'] = $v['goodsMoney']+$shopFreight-$v['promotionMoney'];
|
||||
$data['totalGoodsMoney'] += $v['goodsMoney']-$v['promotionMoney'];
|
||||
$data['totalMoney'] += $v['goodsMoney'] + $shopFreight-$v['promotionMoney'];
|
||||
$total_promotion_money += $v['promotionMoney'];//合计优惠 mark hsf 20170303
|
||||
/*
|
||||
* 计算最大可用惠宝,添加验证批发价的惠宝可抵用 mark hsf 20171117
|
||||
*/
|
||||
// foreach ($v['list'] as &$val) {
|
||||
// if(isset($val['isWhsle'])){//是批发价的
|
||||
// $maxScoreMoney += (int)($val['shopPrice'] * $val['cartNum'] * HuiWhsleScale());//可用惠宝默认抵10%
|
||||
// }else{
|
||||
// $maxScoreMoney += (int)($val['shopPrice'] * $val['cartNum'] * HuiScale());
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
*----------end-------------
|
||||
*/
|
||||
}
|
||||
//批发插件 mart hsf 20171116
|
||||
hook("mobileControllerCartsSettlement",["carts"=>&$carts]);
|
||||
//放钩子计算11.11订单的分类商品使用优惠券后的金额
|
||||
hook("orderCatsCouponEleven",['data'=>&$data,'carts'=>&$carts,'isSettlement'=>true,'uId'=>$userId]);
|
||||
if(isset($data['couponMoney']) && $data['couponMoney'] > 0 ){
|
||||
$total_promotion_money += $data['couponMoney'];
|
||||
}
|
||||
//此处放钩子计算商家使用优惠券后的金额-根据优惠券ID计算
|
||||
hook("afterCalculateCartMoney",["data"=>&$data,'carts'=>$carts,'isVirtual'=>false,'uId'=>$userId]);
|
||||
//ect整合相关优惠还有判断不能和在线支付商品一块
|
||||
hook("ectIntegration",["carts"=>&$carts,'isSettlement'=>true,'uId'=>$userId]);
|
||||
$maxScoreMoney = $data['maxScoreMoneySum']-($total_promotion_money * HuiScale());//减去优惠过的
|
||||
$maxScoreMoney = $maxScoreMoney < 0 ? 0 : $maxScoreMoney;
|
||||
$data['totalGoodsMoney'] = ($data['totalGoodsMoney']>$data['totalMoney'])?$data['totalMoney']:$data['totalGoodsMoney'];
|
||||
//echo $data['totalGoodsMoney'];
|
||||
$data['maxScore'] = 0;
|
||||
$data['maxScoreMoney'] = 0;
|
||||
$data['useScore'] = 0;
|
||||
$data['scoreMoney'] = 0;
|
||||
// //计算最大可用惠宝
|
||||
// /**
|
||||
// * 最多金额抵用20% mark 20170907
|
||||
// */
|
||||
// //$maxScoreMoney = (int)($data['totalGoodsMoney'] * HuiScale());//$data['totalGoodsMoney']; //惠宝最多可抵用20% mark 20170907
|
||||
// $maxScore = WSTScoreToMoney($maxScoreMoney,true);//WSTScoreToMoney($data['totalGoodsMoney'],true);
|
||||
// /*
|
||||
// -------------------end----------------
|
||||
// */
|
||||
// //最大可用惠宝不能大于用户惠宝
|
||||
// $user = model('users')->getFieldsById($userId,'userScore');
|
||||
// if($maxScore>$user['userScore']){
|
||||
// $maxScore = $user['userScore'];
|
||||
// $maxScoreMoney = WSTScoreToMoney($maxScore);
|
||||
// }
|
||||
// $data['maxScore'] = $maxScore;
|
||||
// $data['maxScoreMoney'] = $maxScoreMoney;
|
||||
// //判断是否使用惠宝
|
||||
// $isUseScore = (int)input('isUseScore');
|
||||
// if($isUseScore==1){
|
||||
// //不能比用户惠宝还多
|
||||
// $useScore = (float)input('useScore');
|
||||
// if($useScore>$maxScore)$useScore = $maxScore;
|
||||
// $data['useScore'] = $useScore;
|
||||
// $data['scoreMoney'] = WSTScoreToMoney($useScore);
|
||||
// }
|
||||
// if((isset($carts['is_seckilling']) && $carts['is_seckilling'] == 1) || (isset($carts['promotion_goods']) && $carts['promotion_goods'] == 1)){//不可抵用惠宝
|
||||
// $data['useScore']=0;
|
||||
// $data['scoreMoney']=0;
|
||||
// }
|
||||
//$carts['promotionMoney'] = isset($carts['promotionMoney']) ? $carts['promotionMoney'] : 0;
|
||||
$data['couponMoney'] = isset($data['couponMoney']) ? $data['couponMoney'] : 0;
|
||||
$data['realTotalMoney'] = WSTPositiveNum($data['totalMoney'] - $data['scoreMoney'] - $data['couponMoney']);
|
||||
//dump($data);
|
||||
return WSTReturn('',1,$data);
|
||||
}
|
||||
|
||||
}
|
32
hyhproject/app/model/Chain3.php
Executable file
32
hyhproject/app/model/Chain3.php
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 基础模型器
|
||||
*/
|
||||
class Chain3 extends Chain3base {
|
||||
|
||||
|
||||
protected $tokenabi;
|
||||
protected $bytecode;
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
protected function get_Balance(){
|
||||
$this->wei=8;
|
||||
$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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
115
hyhproject/app/model/Chain3base.php
Executable file
115
hyhproject/app/model/Chain3base.php
Executable file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
Vendor('web3.vendor.autoload');
|
||||
use Web3\Web3;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 基础模型器
|
||||
*/
|
||||
class Chain3base extends Model{
|
||||
|
||||
/**
|
||||
* web3
|
||||
*
|
||||
* @var \Web3\Web3
|
||||
*/
|
||||
protected $web3;
|
||||
|
||||
protected $wei = 18;
|
||||
|
||||
/**
|
||||
* testHost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $testHost = 'http://localhost:8545';
|
||||
|
||||
/**
|
||||
* coinbase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $coinbase=0;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$web3 = new Web3($this->testHost);
|
||||
$this->web3 = $web3;
|
||||
}
|
||||
public function getCoinbase(){
|
||||
$this->web3->eth->coinbase(function ($err, $coinbase) {
|
||||
if ($err !== null) {
|
||||
|
||||
//return $this->fail($err->getMessage());
|
||||
}else{
|
||||
$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
|
||||
*/
|
||||
public function createAccount($pass){
|
||||
$web3->personal->newAccount($pass, function ($err, $account) use (&$newAccount) {
|
||||
if ($err !== null) {
|
||||
return WSTReturn($err->getMessage());
|
||||
// echo 'Error: ' . $err->getMessage();
|
||||
//return;
|
||||
}else{
|
||||
$data['account'] = $account;
|
||||
return WSTReturn('',1,$data);
|
||||
}
|
||||
});
|
||||
}
|
||||
public function getBalance($address){
|
||||
$msg='';
|
||||
$status=-1;
|
||||
$data['balance']=0;
|
||||
$this->web3->eth->getBalance($address , function ($err, $balance) use (&$msg,&$status,&$data) {
|
||||
if ($err !== null) {
|
||||
$msg=$err->getMessage();
|
||||
//return WSTReturn($err->getMessage());
|
||||
//echo 'Error: ' . $err->getMessage();
|
||||
//return;
|
||||
}else{
|
||||
$my_balance = $balance->toString();
|
||||
$my_balance = $my_balance/pow(10,$this->wei);
|
||||
$status=1;
|
||||
$data['balance'] = $my_balance;
|
||||
}
|
||||
});
|
||||
return WSTReturn($msg,$status,$data);
|
||||
}
|
||||
//账号解锁
|
||||
public 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;
|
||||
return WSTReturn('',1,$data);
|
||||
} else {
|
||||
$data['unlock'] = 0;
|
||||
return WSTReturn('',1,$data);
|
||||
//echo 'New account isn\'t unlocked' . PHP_EOL;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
73
hyhproject/app/model/Ect.php
Executable file
73
hyhproject/app/model/Ect.php
Executable file
File diff suppressed because one or more lines are too long
102
hyhproject/app/model/EctElevenPay.php
Executable file
102
hyhproject/app/model/EctElevenPay.php
Executable file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use think\Db;
|
||||
use think\Loader;
|
||||
/**
|
||||
* 双十一优惠券
|
||||
*/
|
||||
class EctElevenPay extends Base{
|
||||
/**
|
||||
* 返回获取双11优惠券所需的ect数量和价格
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getEctNum(){
|
||||
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 = 11.11;//input('total_money');
|
||||
$t_usdt_price = $t_info->data->last;
|
||||
$now_doller = Db::name('doller')->where('id=1')->value('doller');
|
||||
$now_rmb = round($t_usdt_price*$now_doller,2);
|
||||
$to_ect_num = round($total_money/$now_rmb,2);
|
||||
$msg='';
|
||||
session('ect_rmb_price',$now_rmb);
|
||||
exit(jsonReturn($msg,1,['now_rmb'=>$now_rmb,'ect_num'=>$to_ect_num]));
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
exit(jsonReturn('获取价格失败!',-1));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付双十一优惠券的ect价格
|
||||
*/
|
||||
public function payElevenEct(){
|
||||
try{
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
if(!$userId) exit(jsonReturn('请先登录!',-999));
|
||||
//获取用户钱包
|
||||
$user = model('users')->get($userId);
|
||||
|
||||
// if($user->payPwd=='')return WSTReturn('您未设置支付密码,请先设置密码',-1);
|
||||
// if($user->payPwd!=md5($payPwd.$user->loginSecret))return WSTReturn('您的支付密码不正确',-1);
|
||||
$ect_rmb_price = session('ect_rmb_price');
|
||||
if($ect_rmb_price<0.05){
|
||||
exit(jsonReturn('ECT价格出错!',-1));
|
||||
}
|
||||
$price = 11.11;
|
||||
$needPay = round($price/$ect_rmb_price,2);
|
||||
|
||||
$needPay = $needPay > 0 ? $needPay : 0;
|
||||
if($needPay > $user->userECT) exit(jsonReturn('您的钱包ECT不足!',-2));
|
||||
|
||||
$cfgm = Db::name('coupon_record')->where(['couponId'=>11,'userId'=>$userId])->find();
|
||||
if($cfgm){
|
||||
exit(jsonReturn('您已购买过该优惠券,不可重复购买!',-3));
|
||||
}
|
||||
|
||||
//创建一条支出流水记录
|
||||
// $lm = [];
|
||||
// $lm['targetType'] = 0;
|
||||
// $lm['targetId'] = $userId;
|
||||
// $lm['dataId'] = 0;
|
||||
// $lm['dataSrc'] = 1;
|
||||
// $lm['remark'] = '购买双十一神券支出¥'.$needPay;
|
||||
// $lm['moneyType'] = 0;
|
||||
// $lm['money'] = $needPay;
|
||||
// $lm['payType'] = 'ect';
|
||||
// $a = model('common/LogMoneys')->add($lm);
|
||||
|
||||
ectLog($userId,$needPay,11,'11.11神券支出',['userECT'=>['exp','userECT-'.$needPay]],2);
|
||||
|
||||
|
||||
$m = new \addons\hyhcouponset\model\Hyhcouponset();
|
||||
|
||||
$data= $m->giftBag($userId,$secTypeId = 104);
|
||||
// dump($data);die;
|
||||
// Db::commit();
|
||||
exit(jsonReturn('扣款成功!',1));
|
||||
}catch(\Exception $e){
|
||||
// Db::rollback();errLog($e);
|
||||
exit(jsonReturn('扣款失败!',-1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
78
hyhproject/app/model/Favorites.php
Executable file
78
hyhproject/app/model/Favorites.php
Executable file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Favorites as CFavorites;
|
||||
/**
|
||||
* ============================================================================
|
||||
*
|
||||
* ============================================================================
|
||||
* 收藏类
|
||||
*/
|
||||
class Favorites extends CFavorites{
|
||||
/**
|
||||
* 获取会员关注商品数和关注商家数
|
||||
*/
|
||||
function getFavoritesNum($userId){
|
||||
$data['goodsFavoritesNum'] = $this->where(['userId'=>$userId,'favoriteType'=>0])->count();
|
||||
$data['shopFavoritesNum'] = $this->where(['userId'=>$userId,'favoriteType'=>1])->count();
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 获取关注商家数
|
||||
*/
|
||||
function getFavoritesShopsNum($shopId=0){
|
||||
$shopId=$shopId==0?(int)input('shopId'):$shopId;
|
||||
return $this->where(['targetId'=>$shopId,'favoriteType'=>1])->cache('true',3600)->count();
|
||||
}
|
||||
/**
|
||||
* 获取商品是否关注
|
||||
*/
|
||||
function isGetFavorites($goodsId,$userId){
|
||||
$goodsId=$goodsId==0?(int)input('goodsId'):$goodsId;
|
||||
$userId=$userId==0?(int)input('userId'):$userId;
|
||||
return $this->where(['userId'=>$userId,'favoriteType'=>0,'targetId'=>$goodsId])->find();
|
||||
}
|
||||
/**
|
||||
* 上新的店铺列表
|
||||
*/
|
||||
public function listShopQuery(){
|
||||
$pagesize = input("param.pagesize/d",5);
|
||||
$goodsSize = input("param.goodsSize/d",6);
|
||||
$userId = 0;//(int)session('WST_USER.userId');0就是显示所有商铺
|
||||
if($userId){
|
||||
$page = db("favorites")->alias('f')
|
||||
->join('__SHOPS__ s','s.shopId = f.targetId','left')
|
||||
->field('f.favoriteId,f.targetId,s.shopId,s.shopName,s.shopImg')
|
||||
->where(['f.userId'=> $userId,'favoriteType'=> 1])//'s.shopId'=>['in','1,2,3,6,20']])
|
||||
->order('f.favoriteId desc')
|
||||
->paginate($pagesize)->toArray();
|
||||
|
||||
}else{
|
||||
$page = db("shops s")
|
||||
->join('__GOODS__ g','s.shopId = g.shopId','left')
|
||||
->field('s.shopId,count(goodsId) as goodsNum,s.shopName,s.shopImg')
|
||||
->where(['g.isSale'=>1, 'g.goodsStatus'=>1,'g.dataFlag'=>1])
|
||||
->group('g.shopId')
|
||||
->order('saleTime DESC')
|
||||
->cache(true,7200)
|
||||
->paginate($pagesize)
|
||||
->toArray();
|
||||
}
|
||||
foreach ($page['Rows'] as &$v){
|
||||
$field = 'goodsId,goodsImg,saleTime';//goodsName,shopPrice,
|
||||
$goods = db('goods')
|
||||
->where(['dataFlag'=> 1,'isSale'=>1,'goodsStatus'=> 1,'shopId'=> $v["shopId"]])
|
||||
->field($field)
|
||||
->cache(true,7200)
|
||||
->limit($goodsSize)
|
||||
->order('saleTime desc')
|
||||
->select();
|
||||
if($goods){
|
||||
$v['newTime'] = $goods['0']['saleTime'];
|
||||
}else{
|
||||
$v['newTime'] = date('Y-m-d');
|
||||
}
|
||||
$v['goods'] = $goods;
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
}
|
228
hyhproject/app/model/Goods.php
Executable file
228
hyhproject/app/model/Goods.php
Executable file
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Goods as CGoods;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品类
|
||||
*/
|
||||
class Goods extends CGoods{
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
public function pageQuery($goodsCatIds = [], $_where=[]){
|
||||
//查询条件
|
||||
$keyword = input('keyword');
|
||||
$brandId = input('brandId/d');
|
||||
$where = $where2 = [];
|
||||
$where['goodsStatus'] = 1;
|
||||
$where['g.dataFlag'] = 1;
|
||||
$where['isSale'] = 1;
|
||||
if($keyword!='')$where['goodsName'] = ['like','%'.$keyword.'%'];
|
||||
if($brandId>0)$where['g.brandId'] = $brandId;
|
||||
//排序条件
|
||||
$orderBy = input('condition/d',0);
|
||||
$orderBy = ($orderBy>=0 && $orderBy<=4)?$orderBy:0;
|
||||
$order = (input('desc/d',0)==1)?1:0;
|
||||
$pageBy = ['saleNum','shopPrice','visitNum','saleTime'];
|
||||
$pageOrder = ['desc','asc'];
|
||||
if(!empty($goodsCatIds))$where['goodsCatIdPath'] = ['like',implode('_',$goodsCatIds).'_%'];
|
||||
$where = array_merge($where, $_where);
|
||||
$list = Db::name('goods')->alias('g')->join("__SHOPS__ s","g.shopId = s.shopId")
|
||||
->where($where)
|
||||
->field('goodsId,goodsName,saleNum,shopPrice,marketPrice,isSpec,goodsImg,appraiseNum,visitNum,s.shopId,shopName,isSelf,isFreeShipping,gallery')
|
||||
->order($pageBy[$orderBy]." ".$pageOrder[$order].",goodsId asc")
|
||||
->paginate(input('pagesize/d'))->toArray();
|
||||
return $list;
|
||||
}
|
||||
/**
|
||||
* 获取指定商品销量
|
||||
* @param [type] $goodsIds [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getSales($goodsIds){
|
||||
if(is_array($goodsIds)){
|
||||
$where['og.goodsId'] = array('in',$goodsIds);
|
||||
}else{
|
||||
$where['og.goodsId'] = $goodsIds;
|
||||
}
|
||||
$where['o.isPay'] = 1;
|
||||
return Db::name('orders')->alias('o')->join('__ORDER_GOODS__ og','o.orderId=og.orderId')->cache(true,3600)->where($where)->sum('goodsNum');
|
||||
}
|
||||
/**
|
||||
* 获取店铺所有宝贝数量
|
||||
* @param [type] $shopId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getGoodsCount($shopId=0){
|
||||
$shopId=$shopId==0?(int)input('shopId'):$shopId;
|
||||
$where['shopId'] = $shopId;
|
||||
$where['isSale'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['goodsStatus'] = 1;
|
||||
return $this->where($where)->cache(true,3600)->count('goodsId');
|
||||
}
|
||||
/**
|
||||
* 获取店铺上新宝贝数量,一周内的
|
||||
* @param [type] $shopId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getNewGoodsCount($shopId=0){
|
||||
$shopId=$shopId==0?(int)input('shopId'):$shopId;
|
||||
$where['shopId'] = $shopId;
|
||||
$where['isSale'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['goodsStatus'] = 1;
|
||||
return $this->where($where)->whereTime('saleTime','last week')->cache(true,3600)->count('goodsId');
|
||||
}
|
||||
/**
|
||||
* 获取新品
|
||||
* @param [type] $goodsIds [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getNew($goodsIds){
|
||||
if(is_array($goodsIds)){
|
||||
$where['og.goodsId'] = array('in',$goodsIds);
|
||||
}else{
|
||||
$where['og.goodsId'] = $goodsIds;
|
||||
}
|
||||
$where['o.isPay'] = 1;
|
||||
return Db::name('orders')->alias('o')->join('__ORDER_GOODS__ og','o.orderId=og.orderId')->cache(true,3600)->where($where)->sum('goodsNum');
|
||||
}
|
||||
/**
|
||||
* 获取商品资料在前台展示
|
||||
*/
|
||||
public function getBySale($goodsId){
|
||||
$key = input('key');
|
||||
// 浏览量
|
||||
$this->where('goodsId',$goodsId)->setInc('visitNum',1);
|
||||
$rs = Db::name('goods')->where(['goodsId'=>$goodsId,'dataFlag'=>1])->find();
|
||||
if(!empty($rs)){
|
||||
$rs['read'] = false;
|
||||
//判断是否可以公开查看
|
||||
$viKey = WSTShopEncrypt($rs['shopId']);
|
||||
if(($rs['isSale']==0 || $rs['goodsStatus']==0) && $viKey != $key)return [];
|
||||
if($key!='')$rs['read'] = true;
|
||||
//获取店铺信息
|
||||
$rs['shop'] = model('shops')->getBriefShop((int)$rs['shopId']);
|
||||
if(empty($rs['shop']))return [];
|
||||
//获取商店的授权商店分类和商铺电话信息
|
||||
// $goodsCats = Db::name('cat_shops')->alias('cs')->join('__GOODS_CATS__ gc','cs.catId=gc.catId and gc.dataFlag=1','left')->join('__SHOPS__ s','s.shopId = cs.shopId','left')
|
||||
// ->where('cs.shopId',$rs['shopId'])->field('cs.shopId,s.shopTel,gc.catId,gc.catName')->select();
|
||||
// $rs['shop']['catId'] = $goodsCats[0]['catId'];
|
||||
// $rs['shop']['shopTel'] = $goodsCats[0]['shopTel'];
|
||||
|
||||
// $cat = [];
|
||||
// foreach ($goodsCats as $v){
|
||||
// $cat[] = $v['catName'];
|
||||
// }
|
||||
// $rs['shop']['cat'] = implode(',',$cat);
|
||||
// if(empty($rs['shop']))return [];
|
||||
$gallery = [];
|
||||
$gallery[] = $rs['goodsImg'];
|
||||
|
||||
if($rs['gallery']!=''){//有多个图片就把多个一维图片地址合成一个数组
|
||||
$tmp = explode(',',$rs['gallery']);
|
||||
$gallery = array_merge($gallery,$tmp);
|
||||
}
|
||||
|
||||
$rs['gallery'] = $gallery;
|
||||
//获取规格值
|
||||
$specs = Db::name('spec_cats')->alias('gc')->join('__SPEC_ITEMS__ sit','gc.catId=sit.catId','inner')
|
||||
->where(['sit.goodsId'=>$goodsId,'gc.isShow'=>1,'sit.dataFlag'=>1])
|
||||
->field('gc.isAllowImg,gc.catName,sit.catId,sit.itemId,sit.itemName,sit.itemImg')
|
||||
->order('gc.isAllowImg desc,gc.catSort asc,gc.catId asc')->select();
|
||||
$rs['spec']=[];
|
||||
//把属于同一个分类的规格整合到一块
|
||||
foreach ($specs as $key =>$v){
|
||||
$rs['spec'][$v['catId']]['name'] = $v['catName'];
|
||||
$rs['spec'][$v['catId']]['list'][] = $v;
|
||||
}
|
||||
//dump($rs['spec']);die;
|
||||
//获取销售规格,商品规格的具体属性
|
||||
$sales = Db::name('goods_specs')->where(['goodsId'=>$goodsId,'dataFlag'=>1])->field('id,isDefault,productNo,specIds,marketPrice,specPrice,specStock,initNum,whslePrice')->select();
|
||||
if(!empty($sales)){
|
||||
//将规格ID格式如:3:4:5:6:7,设为数组键名,与$rs['spec']['catId']['list']['itemId'] 对应
|
||||
/*实例
|
||||
//$specs转换后$rs['spec']数据
|
||||
[11] => array(2) {//11代表规格分类ID
|
||||
["name"] => string(12) "机身颜色"//规格分类名称
|
||||
["list"] => array(2) {//当前分类11下的数据
|
||||
[0] => array(6) {
|
||||
["isAllowImg"] => int(1)
|
||||
["catName"] => string(12) "机身颜色"
|
||||
["catId"] => int(11)
|
||||
["itemId"] => int(5)//这个即代表数据的ID,3:4:(5):6:7就是对应的这个
|
||||
["itemName"] => string(6) "黄色"
|
||||
["itemImg"] => string(44) "upload/goods/2017-11/5a0a7e2ee935c_thumb.jpg"
|
||||
}
|
||||
[1] => array(6) {
|
||||
["isAllowImg"] => int(1)
|
||||
["catName"] => string(12) "机身颜色"
|
||||
["catId"] => int(11)
|
||||
["itemId"] => int(10)
|
||||
["itemName"] => string(6) "灰色"
|
||||
["itemImg"] => string(44) "upload/goods/2017-11/5a0a7e3970fed_thumb.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
//$sales原始数据
|
||||
[0] => array(7) {
|
||||
["id"] => int(3)
|
||||
["isDefault"] => int(1)
|
||||
["productNo"] => string(1) "3"
|
||||
["specIds"] => string(9) "3:4:5:6:7"
|
||||
["marketPrice"] => string(7) "1070.00"
|
||||
["specPrice"] => string(7) "1002.00"
|
||||
["specStock"] => int(0)
|
||||
}
|
||||
//$sales下面转换后数据
|
||||
["3:4:5:6:7"] => array(6) {
|
||||
["id"] => int(3)
|
||||
["isDefault"] => int(1)
|
||||
["productNo"] => string(1) "3"
|
||||
["marketPrice"] => string(7) "1070.00"
|
||||
["specPrice"] => string(7) "1002.00"
|
||||
["specStock"] => int(0)
|
||||
}*/
|
||||
foreach ($sales as $key =>$v){
|
||||
$str = explode(':',$v['specIds']);
|
||||
sort($str);
|
||||
unset($v['specIds']);
|
||||
$rs['saleSpec'][implode(':',$str)] = $v;
|
||||
}
|
||||
}
|
||||
//获取商品属性
|
||||
$rs['attrs'] = Db::name('attributes')->alias('a')->join('goods_attributes ga','a.attrId=ga.attrId','inner')
|
||||
->where(['a.isShow'=>1,'dataFlag'=>1,'goodsId'=>$goodsId])->field('a.attrName,ga.attrVal')
|
||||
->order('attrSort asc')->select();
|
||||
//获取商品评分
|
||||
$rs['scores'] = Db::name('goods_scores')->where('goodsId',$goodsId)->field('totalScore,totalUsers')->find();
|
||||
$rs['scores']['totalScores'] = ($rs['scores']['totalScore']==0)?5:WSTScore($rs['scores']['totalScore'],$rs['scores']['totalUsers'],5,0,3);
|
||||
WSTUnset($rs, 'totalUsers');
|
||||
//关注
|
||||
$f = model('Favorites');
|
||||
$rs['favShop'] = $f->checkFavorite($rs['shopId'],1);
|
||||
$rs['favGood'] = $f->checkFavorite($goodsId,0);
|
||||
//$rs['isEct'] = (int)Db::name('goods_pay')->where('goodsId',$goodsId)->value('ectPay');
|
||||
}
|
||||
//dump($rs);die;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
public function historyQuery(){
|
||||
$ids = cookie("wx_history_goods");
|
||||
if(empty($ids))return [];
|
||||
$where = [];
|
||||
$where['isSale'] = 1;
|
||||
$where['goodsStatus'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['goodsId'] = ['in',$ids];
|
||||
$orderBy = "field(`goodsId`,".implode(',',$ids).")";
|
||||
return Db::name('goods')
|
||||
->where($where)->field('goodsId,goodsName,goodsImg,saleNum,shopPrice')
|
||||
->order($orderBy)
|
||||
->paginate((int)input('pagesize'))->toArray();
|
||||
}
|
||||
}
|
61
hyhproject/app/model/GoodsAppraises.php
Executable file
61
hyhproject/app/model/GoodsAppraises.php
Executable file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\GoodsAppraises as CGoodsAppraises;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 评价类
|
||||
*/
|
||||
class GoodsAppraises extends CGoodsAppraises{
|
||||
/**
|
||||
* 获取评论
|
||||
*/
|
||||
public function getAppr(){
|
||||
$oId = (int)input('oId');
|
||||
$uId = (int)session('WST_USER.userId');
|
||||
$gId = (int)input('gId');
|
||||
$specId = (int)input('sId');
|
||||
$orderGoodsId = (int)input('orderGoodsId');
|
||||
$rs = $this->where(['orderId'=>$oId,'userId'=>$uId,'goodsId'=>$gId,'goodsSpecId'=>$specId,'orderGoodsId'=>$orderGoodsId])->find();
|
||||
if($rs!==false){
|
||||
$rs = !empty($rs)?$rs:['goodsScore'=>'','timeScore'=>'','serviceScore'=>'','content'=>''];
|
||||
return jsonReturn('',1,$rs);
|
||||
}
|
||||
return jsonReturn('获取出错',-1);
|
||||
}
|
||||
/**
|
||||
* 根据商品id取一试图评论
|
||||
*/
|
||||
public function getOneAppraises($goodsId){
|
||||
$goodsId=$goodsId==0?(int)input('goodsId'):$goodsId;
|
||||
// 处理匿名
|
||||
$anonymous = 1;
|
||||
$where = ['ga.goodsId'=>$goodsId,
|
||||
'ga.dataFlag'=>1,
|
||||
'ga.isShow'=>1];
|
||||
$rs = $this->alias('ga')
|
||||
->field('DISTINCT(ga.id),ga.content,ga.images,ga.shopReply,ga.replyTime,ga.createTime,ga.goodsScore,ga.serviceScore,ga.timeScore,ga.shopId,u.userPhoto,u.loginName,u.userPhone,og.goodsSpecNames')
|
||||
->join('__USERS__ u','ga.userId=u.userId','left')
|
||||
->join('__ORDER_GOODS__ og','og.orderId=ga.orderId and og.goodsId=ga.goodsId','inner')
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->find();
|
||||
|
||||
if($rs){
|
||||
// 格式化时间
|
||||
//$rs['createTime'] = date('Y-m-d',strtotime($rs['createTime']));
|
||||
$rs['goodsSpecNames'] = str_replace('@@_@@',',',$rs['goodsSpecNames']);
|
||||
// 总评分
|
||||
//$rs['avgScore'] = ceil(($rs['goodsScore'] + $rs['serviceScore'] + $rs['timeScore'])/3);
|
||||
if($anonymous){
|
||||
$start = floor((strlen($rs['userPhone'])/2))-1;
|
||||
$rs['userPhone'] = substr_replace($rs['userPhone'],'***',$start,3);
|
||||
$rs['loginName'] = $rs['userPhone'];
|
||||
}
|
||||
}else{
|
||||
$rs = [];
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
}
|
96
hyhproject/app/model/GoodsCats.php
Executable file
96
hyhproject/app/model/GoodsCats.php
Executable file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use think\Cache;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品分类类
|
||||
*/
|
||||
class GoodsCats extends Base{
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function getGoodsCats(){
|
||||
$list = cache('WST_CACHE_GOODS_CAT_MOB');
|
||||
if(!$list){
|
||||
//查询一级分类
|
||||
$trs1s = $this->where(["dataFlag"=>1,"isShow"=>1,"parentId"=>0])->field('catId,parentId,catName')->order('catSort asc')->select();
|
||||
$trs1 = array();
|
||||
$list = array();
|
||||
$rs2 = array();
|
||||
$maprs = array();
|
||||
$ids = array();
|
||||
foreach ($trs1s as $key =>$v){
|
||||
$trs1[$key]['catId'] = $v['catId'];
|
||||
$trs1[$key]['parentId'] = $v['parentId'];
|
||||
$trs1[$key]['catName'] = $v['catName'];
|
||||
$ids[] = $v['catId'];
|
||||
}
|
||||
$ids[] = -1;
|
||||
//查询二级分类
|
||||
$trs2s = $this->where("dataFlag=1 and isShow=1 and parentId in(".implode(',',$ids).")")->field('catId,parentId,catName')->order('catSort asc')->select();
|
||||
$trs2 = array();
|
||||
$ids = array();
|
||||
foreach ($trs2s as $key =>$v){
|
||||
$trs2[$key]['catId'] = $v['catId'];
|
||||
$trs2[$key]['parentId'] = $v['parentId'];
|
||||
$trs2[$key]['catName'] = $v['catName'];
|
||||
}
|
||||
foreach ($trs2 as $v2){
|
||||
$ids[] = $v2['catId'];
|
||||
$maprs[$v2['parentId']][] = $v2;
|
||||
}
|
||||
$ids[] = -1;
|
||||
//查询三级分类
|
||||
$trs3s = $this->where("dataFlag=1 and isShow=1 and parentId in(".implode(',',$ids).")")->field('catId,parentId,catName,catImg')->order('catSort asc')->select();
|
||||
$trs3 = array();
|
||||
$ids = array();
|
||||
foreach ($trs3s as $key =>$v){
|
||||
$trs3[$key]['catId'] = $v['catId'];
|
||||
$trs3[$key]['parentId'] = $v['parentId'];
|
||||
$trs3[$key]['catName'] = $v['catName'];
|
||||
$trs3[$key]['catImg'] = strval($v['catImg']);
|
||||
}
|
||||
foreach ($trs3 as $v2){
|
||||
$maprs[$v2['parentId']][] = $v2;
|
||||
}
|
||||
//倒序建立樹形
|
||||
foreach ($trs2 as $v2){
|
||||
$v2['childList'] = [];
|
||||
if(isset($maprs[$v2['catId']]))$v2['childList'] = $maprs[$v2['catId']];
|
||||
$rs2[] = $v2;
|
||||
}
|
||||
foreach ($trs1 as $v2){
|
||||
foreach ($rs2 as $vv2){
|
||||
if($vv2['parentId']==$v2['catId']){
|
||||
$v2['childList'][] = $vv2;
|
||||
}
|
||||
}
|
||||
$list[] = $v2;
|
||||
}
|
||||
Cache::set('WST_CACHE_GOODS_CAT_MOB',$list);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
/**
|
||||
* 获取分类名
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getCatName(){
|
||||
$catId = (int)input('post.catId');
|
||||
$rs = $this->where(['catId'=>$catId])->field('catName')->find();
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 获取分类信息
|
||||
* @param integer $parentId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getGoodsCat($parentId=0){
|
||||
$parentId=$parentId==0?(int)input('parentId'):$parentId;
|
||||
$field = 'catId,parentId,catName,catImg';
|
||||
// if($parentId > 0){//不是父级分类要加小图片
|
||||
// $field .= ',catImg';
|
||||
// }
|
||||
return $this->where(["dataFlag"=>1,"isShow"=>1,"parentId"=>$parentId])->field($field)->order('catSort asc')->cache(true,864000)->select();
|
||||
}
|
||||
}
|
227
hyhproject/app/model/Index.php
Executable file
227
hyhproject/app/model/Index.php
Executable file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Tags as T;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认类
|
||||
*/
|
||||
class Index extends Base{
|
||||
/**
|
||||
* 楼层
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$limit = (int)input('post.currPage');//楼层页码
|
||||
if($limit>9)return;
|
||||
$cacheData = cache('MO_CATS_ADS'.$limit);
|
||||
if($cacheData)return $cacheData;
|
||||
$rs = Db::name('goods_cats')->where(['dataFlag'=>1,'isShow'=>1,'parentId'=>0,'isFloor'=>1])->field('catId,catName')->order('catSort asc')->limit($limit,1)->select();//按设定排序获取分类名称,异步下拉加载,传输楼层的层楼
|
||||
if($rs){
|
||||
$rs= $rs[0];//用select就选第一个,其实可以改成find
|
||||
$t = new T();
|
||||
$rs['ads'] = $t->listAds('mo-ads-'.$limit,'1');//获取手机版楼层页面的广告图
|
||||
$rs['goods'] = Db::name('goods')->alias('g')->join('__RECOMMENDS__ r','g.goodsId=r.dataId')
|
||||
->where(['r.goodsCatId'=>$rs['catId'],'g.isSale'=>1,'g.dataFlag'=>1,'g.goodsStatus'=>1,'r.dataSrc'=>0,'r.dataType'=>1])
|
||||
->field('g.goodsId,g.goodsName,g.goodsImg,g.shopPrice,g.saleNum')->order('r.dataSort asc')->limit(6)->select();
|
||||
if(empty($rs['goods'])){
|
||||
$rs['goods'] = Db::name('goods')->alias('g')
|
||||
->where(['g.goodsCatIdPath'=>['like',$rs['catId'].'_%'],'g.isSale'=>1,'g.dataFlag'=>1,'g.goodsStatus'=>1,'g.isHot'=>1])
|
||||
->field('g.goodsId,g.goodsName,g.goodsImg,g.shopPrice,g.saleNum')
|
||||
->order('saleNum desc,goodsId asc')->limit(6)->select();
|
||||
}
|
||||
$rs['currPage'] = $limit;
|
||||
}
|
||||
cache('MO_CATS_ADS'.$limit,$rs,86400);
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 猜你喜欢
|
||||
*/
|
||||
public function guess_like(){
|
||||
$userId=(int)session('WST_USER.userId');
|
||||
//$userId=50;
|
||||
$page = (int)input('post.page/d');
|
||||
$cacheData = cache('APP_CATS_LIKE_'.$page.'_'.$userId);
|
||||
if($cacheData)return $cacheData;
|
||||
$pagesize = input('pagesize/d');
|
||||
$childId=[];
|
||||
$parentId=[];
|
||||
//$goods_result["Rows"]= '';//Db::name('goods')->alias('g')->join('__RECOMMENDS__ r','g.goodsId=r.dataId')
|
||||
//->where(['g.isSale'=>1,'g.dataFlag'=>1,'g.goodsStatus'=>1,'r.dataSrc'=>0,'r.dataType'=>1])
|
||||
//->field('g.goodsId,g.goodsName,g.goodsImg,g.shopPrice,g.saleNum')->order('rand()')->paginate($pagesize)->toArray();
|
||||
//用户登录状态
|
||||
// if($userId){
|
||||
// //查找登录账号浏览过的记录
|
||||
// $goods_ids=db('page_view')->where('userId',$userId)->field('count(goodsId)num,goodsId')
|
||||
// ->group('goodsId')->order('num desc')->limit('18')->select();
|
||||
// if($goods_ids){
|
||||
// foreach($goods_ids as $key=>$value){
|
||||
// $childId[]=$value['goodsId'];
|
||||
// }
|
||||
// //根据查找到的商品分类,寻找最顶级商品分类
|
||||
// $goods_parents=$this->getParentIs($childId);
|
||||
// foreach($goods_parents as $k=>$v){
|
||||
// $parentId[]=$v;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
//用户未登录或顶级商品分类过少时进行全表查询
|
||||
if(!$userId || count($parentId)<3){
|
||||
|
||||
$goods_ids=db('page_view')->where('1=1')->field('count(goodsId)num,goodsId')
|
||||
->group('goodsId')->order('num desc,id desc')->limit('18')->select();
|
||||
foreach($goods_ids as $key=>$value){
|
||||
$childId[]=$value['goodsId'];
|
||||
}
|
||||
////根据查找到的商品分类,寻找最顶级商品分类
|
||||
$goods_parents=$this->getParentIs($childId);
|
||||
foreach($goods_parents as $k=>$v){
|
||||
$parentId[]=$v;
|
||||
}
|
||||
}
|
||||
//根据父级分类查找所有子级商品
|
||||
$goods_child=$this->getChild('',$parentId);
|
||||
$pagesize = input('pagesize/d');
|
||||
//展现顶级分类下所有子级分类的商品
|
||||
$goods_result=db('goods')->whereIn('goodsCatId',$goods_child)->order('visitNum desc')
|
||||
->where(['isSale'=>1,'dataFlag'=>1,'goodsStatus'=>1,'isHot'=>1])
|
||||
->field('goodsId,goodsName,goodsImg,shopPrice,saleNum')
|
||||
->paginate($pagesize)->toArray();
|
||||
// if(empty($goods_result["Rows"])){
|
||||
// $goods_result = Db::name('goods')->alias('g')
|
||||
// ->where(['g.isSale'=>1,'g.dataFlag'=>1,'g.goodsStatus'=>1,'g.isHot'=>1])
|
||||
// ->field('g.goodsId,g.goodsName,g.goodsImg,g.shopPrice,g.saleNum')
|
||||
// ->order('rand()')->paginate($pagesize)->toArray();
|
||||
// }
|
||||
|
||||
cache('APP_CATS_LIKE_'.$page.'_'.$userId,$goods_result,3600);
|
||||
return $goods_result;
|
||||
}
|
||||
/**
|
||||
* 热卖推荐
|
||||
*/
|
||||
public function getHotGoods(){
|
||||
$page = (int)input('page',1);
|
||||
$cacheData = cache('QLG_HOT_GOODS_'.$page);
|
||||
if($cacheData)return $cacheData;
|
||||
$rs = Db::name('goods')
|
||||
->where(['isSale'=>1,'dataFlag'=>1,'goodsStatus'=>1])
|
||||
->field('goodsId,goodsName,goodsImg,shopPrice,saleNum,discountRate')
|
||||
->order('discountRate DESC,goodsId DESC')
|
||||
->paginate(input('pageSize/d',10))->toArray();
|
||||
cache('QLG_HOT_GOODS_'.$page,$rs,3600);
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 迭代获取下级
|
||||
* 获取一个分类下的所有子级分类id
|
||||
*/
|
||||
public function getChild($data,$pid){
|
||||
if(!$pid){
|
||||
return;
|
||||
}
|
||||
$childId = db('goods_cats')->where("dataFlag=1")->whereIn('parentId',$pid)->field('catId,parentId')->select();
|
||||
//获取该分类id下的所有子级分类id
|
||||
foreach($childId as $key=>$value){
|
||||
$child[]=$value['catId'];
|
||||
}
|
||||
static $ids = array();
|
||||
foreach($childId as $k=>$v){
|
||||
//dump($childId);
|
||||
$ids[] = $v['catId'];//将找到的下级分类id放入静态数组
|
||||
//再找下当前id是否还存在下级id
|
||||
$this->getChild($childId, $v['catId']);
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
/**
|
||||
* 根据子分类获取其父级分类
|
||||
*/
|
||||
public function getParentIs($id,$data = array()){
|
||||
$data[] = $id;
|
||||
$parentId = db('goods_cats')->where("dataFlag=1")->whereIn('catId',$id)->field('parentId')->select();
|
||||
foreach($parentId as $key=>$value){
|
||||
$parent[]=$value['parentId'];
|
||||
}
|
||||
|
||||
if(!isset($parent)){
|
||||
krsort($data);
|
||||
//判断是否有值为0的数组元素;
|
||||
foreach ($data as $k => $v) {
|
||||
foreach ($v as $key => $value) {
|
||||
if(!$value){
|
||||
unset($v[$key]);
|
||||
}
|
||||
}
|
||||
if(!$v){
|
||||
unset($data[$k]);
|
||||
}
|
||||
}
|
||||
$da=array_unique(current($data));
|
||||
return $da;
|
||||
}else{
|
||||
return $this->getParentIs($parent,$data);
|
||||
}
|
||||
}
|
||||
//获取所有小广告位
|
||||
public function getIndexAds(){
|
||||
$cacheData = cache('APP_CATS_ADS');
|
||||
if($cacheData)return $cacheData;
|
||||
$where['positionCode'] = ['LIKE','%mo-ads-index-%'];
|
||||
$where['positionType'] = 3;
|
||||
$where['dataFlag'] = 1;
|
||||
$positions_list = Db::name('ad_positions')->where($where)->field('positionId,positionName')->cache(true,86400)->select();
|
||||
unset($where['positionCode'] );
|
||||
$date = date('Y-m-d');
|
||||
$where['adStartDate'] = ['<=',$date];
|
||||
$where['adEndDate'] = ['>=',$date];
|
||||
$list=[];
|
||||
foreach($positions_list as &$v){
|
||||
$where['adPositionId'] = $v['positionId'];
|
||||
$list[$v['positionId']]['name'] = $v['positionName'];
|
||||
$ads_list = Db::name('ads')->where($where)->field('adFile,adURL,targetType')->cache(true,86400)->select();
|
||||
$list[$v['positionId']]['list'] = $ads_list;
|
||||
}
|
||||
cache('APP_CATS_ADS',$list,86400);
|
||||
return $list;
|
||||
}
|
||||
//获取首页轮播图
|
||||
public function getIndexTopImg(){
|
||||
$cacheData = cache('APP_TOP_IMG');
|
||||
if($cacheData)return $cacheData;
|
||||
$ads_list=[];
|
||||
$ads_list = listAds('mo-ads-index',9,86400);
|
||||
cache('APP_TOP_IMG',$ads_list,86400);
|
||||
return $ads_list;
|
||||
}
|
||||
//获取首页横图
|
||||
public function getIndexCrossImg(){
|
||||
$cacheData = cache('APP_CROSS_IMG');
|
||||
if($cacheData)return $cacheData;
|
||||
$ads_list=[];
|
||||
$ads_list['cross_top'] = listAds('mo-index-cross-top',6,86400);
|
||||
$ads_list['cross_bottom'] = listAds('mo-index-cross-down',6,86400);
|
||||
cache('APP_CROSS_IMG',$ads_list,86400);
|
||||
return $ads_list;
|
||||
}
|
||||
/**
|
||||
* 获取系统消息
|
||||
*/
|
||||
function getSysMsg($msg='',$order=''){
|
||||
$data = [];
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
if($msg!=''){
|
||||
$data['message']['num'] = Db::name('messages')->where(['receiveUserId'=>$userId,'msgStatus'=>0,'dataFlag'=>1])->count();
|
||||
}
|
||||
if($order!=''){
|
||||
$data['order']['waitPay'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>-2,'dataFlag'=>1])->count();
|
||||
$data['order']['waitSend'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>0,'dataFlag'=>1])->count();
|
||||
$data['order']['waitReceive'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>1,'dataFlag'=>1])->count();
|
||||
$data['order']['waitAppraise'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>2,'isAppraise'=>0,'dataFlag'=>1])->count();
|
||||
$data['order']['cancelNum'] = 0;//Db::name('orders')->where('userId='.$userId.' AND (orderStatus=-1 OR orderStatus=-3)')->count();
|
||||
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
106
hyhproject/app/model/Messages.php
Executable file
106
hyhproject/app/model/Messages.php
Executable file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use think\Db;
|
||||
use wstmart\common\model\Messages as CMessages;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商城消息
|
||||
*/
|
||||
class Messages extends CMessages{
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$from = input('from/d');
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$where['receiveUserId'] = (int)$userId;
|
||||
$where['dataFlag'] = 1;
|
||||
if(isset($from)){
|
||||
$where['from'] = $from;
|
||||
}
|
||||
$page = $this->where($where)->order('msgStatus asc,id desc')->cache(true,30)->paginate(input('pagesize/d'))->toArray();
|
||||
// foreach ($page['Rows'] as $key => $v){
|
||||
// $page['Rows'][$key]['msgContent'] = WSTMSubstr(strip_tags(htmlspecialchars_decode($v['msgContent'])),0,140);
|
||||
// }
|
||||
foreach ($page['Rows'] as &$v){
|
||||
if($v['from'] == 1){
|
||||
$msgJson = json_decode($v['msgJson']);
|
||||
//dump($msgJson);die;
|
||||
$shopId = Db::name('orders')->where(['orderId'=>$msgJson->dataId])->cache(true,86400)->value('shopId');
|
||||
$shopImg = Db::name('shops')->where(['shopId'=>$shopId])->cache(true,86400)->value('shopImg');
|
||||
// Db::name('order o')
|
||||
// ->join('__SHOPS s','o.shopId=s.shopId','inner join')
|
||||
// ->field('shopId,shopImg')
|
||||
// ->where(['o.orderId'=>$msgJson['dataId']])
|
||||
// ->cache(true,86400)
|
||||
// ->find();
|
||||
$v['img'] = WSTImg($shopImg,3);
|
||||
}else{
|
||||
$v['img'] = '';
|
||||
}
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
/**
|
||||
* 获取某一条消息详情
|
||||
*/
|
||||
public function getById(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$id = (int)input('msgId');
|
||||
$data = $this->get(['id'=>$id,'receiveUserId'=>$userId]);
|
||||
if(!empty($data)){
|
||||
//$data['msgContent'] = htmlspecialchars_decode($data['msgContent']);
|
||||
if($data['msgStatus']==0)
|
||||
model('Messages')->where('id',$id)->setField('msgStatus',1);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$id = input('id/d');
|
||||
$data = [];
|
||||
$data['dataFlag'] = -1;
|
||||
$result = $this->update($data,['id'=>$id,'receiveUserId'=>$userId]);
|
||||
if(false !== $result){
|
||||
return WSTReturn("删除成功", 1);
|
||||
}else{
|
||||
return WSTReturn($this->getError(),-1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public function batchDel(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$ids = input('ids/a');
|
||||
$data = [];
|
||||
$data['dataFlag'] = -1;
|
||||
$result = $this->update($data,['id'=>['in',$ids],'receiveUserId'=>$userId]);
|
||||
if(false !== $result){
|
||||
return WSTReturn("删除成功", 1);
|
||||
}else{
|
||||
return WSTReturn($this->getError(),-1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 标记为已读
|
||||
*/
|
||||
public function batchRead(){
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$ids = input('ids/a');
|
||||
$data = [];
|
||||
$data['msgStatus'] = 1;
|
||||
$result = $this->update($data,['id'=>['in',$ids],'receiveUserId'=>$userId]);
|
||||
if(false !== $result){
|
||||
return WSTReturn("操作成功", 1);
|
||||
}else{
|
||||
return WSTReturn($this->getError(),-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
13
hyhproject/app/model/Orders.php
Executable file
13
hyhproject/app/model/Orders.php
Executable file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Orders as COrders;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 订单类
|
||||
*/
|
||||
class Orders extends COrders{
|
||||
function getOrderByOrderNo($orderNo,$field='*'){
|
||||
return $this->where(['dataFlag'=>1,'orderNo|orderunique'=>$orderNo])->field($field)->find();
|
||||
}
|
||||
}
|
9
hyhproject/app/model/Payments.php
Executable file
9
hyhproject/app/model/Payments.php
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Payments as CPayments;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 支付管理业务处理
|
||||
*/
|
||||
class Payments extends CPayments{
|
||||
}
|
291
hyhproject/app/model/Shops.php
Executable file
291
hyhproject/app/model/Shops.php
Executable file
@ -0,0 +1,291 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Shops as CShops;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 门店类
|
||||
*/
|
||||
class Shops extends CShops{
|
||||
public function getShopIndex(){
|
||||
$shopId = (int)input('shopId');
|
||||
$shopInfo = $this->where(['shopId'=>$shopId,'status'=>1,'shopStatus'=>1,'dataFlag'=>1])->field('shopImg,shopName,lat,lng,userName,phone')->find();
|
||||
if(!$shopInfo) return WSTReturn('未找到此店铺');
|
||||
$shopInfo['shopAds'] = (string)Db::name('shop_configs')->where(['shopId'=>$shopId])->value('shopAds');
|
||||
return WSTReturn('',1,$shopInfo);
|
||||
}
|
||||
/**
|
||||
* 店铺街列表
|
||||
*/
|
||||
public function pageQuery($pagesize){
|
||||
$catId = (int)input("id");
|
||||
$keyword = input("keyword");
|
||||
$condition = input("condition");
|
||||
$desc = input("desc");
|
||||
$datas = array('sort'=>array('1'=>'ss.totalScore/ss.totalUsers'),'desc'=>array('desc','asc'));
|
||||
$rs = $this->alias('s');
|
||||
$where = [];
|
||||
$where['s.dataFlag'] = 1;
|
||||
$where['s.shopStatus'] = 1;
|
||||
$where['s.status'] = 1;
|
||||
if($keyword!='')$where['s.shopName'] = ['like','%'.$keyword.'%'];
|
||||
if($catId>0){
|
||||
$rs->join('__CAT_SHOPS__ cs','cs.shopId = s.shopId','left');
|
||||
$where['cs.catId'] = $catId;
|
||||
}
|
||||
$order = ['s.shopId'=>'asc'];
|
||||
if($condition>0){
|
||||
$order = [$datas['sort'][$condition]=>$datas['desc'][$desc]];
|
||||
}
|
||||
$page = $rs->join('__SHOP_SCORES__ ss','ss.shopId = s.shopId','left')
|
||||
->where($where)->order($order)
|
||||
->field('s.shopId,s.shopImg,s.shopName,s.shopCompany,ss.totalScore,ss.totalUsers,ss.goodsScore,ss.goodsUsers,ss.serviceScore,ss.serviceUsers,ss.timeScore,ss.timeUsers,s.areaIdPath')
|
||||
->paginate($pagesize)->toArray();
|
||||
foreach ($page['Rows'] as $key =>$v){
|
||||
//商品列表
|
||||
$goods = db('goods')->where(['dataFlag'=> 1,'isSale'=>1,'goodsStatus'=> 1,'shopId'=> $v["shopId"]])->field('goodsId,goodsName,shopPrice,goodsImg')
|
||||
->order('saleTime desc')->limit(3)->select();
|
||||
$page['Rows'][$key]['goods'] = $goods;
|
||||
}
|
||||
if(empty($page['Rows']))return $page;
|
||||
$shopIds = [];
|
||||
$areaIds = [];
|
||||
foreach ($page['Rows'] as $key =>$v){
|
||||
$shopIds[] = $v['shopId'];
|
||||
// $tmp = explode('_',$v['areaIdPath']);
|
||||
// $areaIds[] = $tmp[1];
|
||||
//$page['Rows'][$key]['areaId'] = $tmp[1];
|
||||
//总评分
|
||||
$page['Rows'][$key]['totalScore'] = WSTScore($v["totalScore"]/3, $v["totalUsers"]);
|
||||
$page['Rows'][$key]['goodsScore'] = WSTScore($v['goodsScore'],$v['goodsUsers']);
|
||||
$page['Rows'][$key]['serviceScore'] = WSTScore($v['serviceScore'],$v['serviceUsers']);
|
||||
$page['Rows'][$key]['timeScore'] = WSTScore($v['timeScore'],$v['timeUsers']);
|
||||
}
|
||||
$rccredMap = [];
|
||||
$goodsCatMap = [];
|
||||
$areaMap = [];
|
||||
//认证、地址、分类
|
||||
if(!empty($shopIds)){
|
||||
$rccreds = Db::name('shop_accreds')->alias('sac')->join('__ACCREDS__ a','a.accredId=sac.accredId and a.dataFlag=1','left')
|
||||
->where('shopId','in',$shopIds)->field('sac.shopId,accredName,accredImg')->select();
|
||||
foreach ($rccreds as $v){
|
||||
$rccredMap[$v['shopId']][] = $v;
|
||||
}
|
||||
$goodsCats = Db::name('cat_shops')->alias('cs')->join('__GOODS_CATS__ gc','cs.catId=gc.catId and gc.dataFlag=1','left')
|
||||
->where('shopId','in',$shopIds)->field('cs.shopId,gc.catName')->select();
|
||||
foreach ($goodsCats as $v){
|
||||
$goodsCatMap[$v['shopId']][] = $v['catName'];
|
||||
}
|
||||
$areas = Db::name('areas')->alias('a')->join('__AREAS__ a1','a1.areaId=a.parentId','left')
|
||||
->where('a.areaId','in',$areaIds)->field('a.areaId,a.areaName areaName2,a1.areaName areaName1')->select();
|
||||
foreach ($areas as $v){
|
||||
$areaMap[$v['areaId']] = $v;
|
||||
}
|
||||
}
|
||||
foreach ($page['Rows'] as $key =>$v){
|
||||
$page['Rows'][$key]['accreds'] = (isset($rccredMap[$v['shopId']]))?$rccredMap[$v['shopId']]:[];
|
||||
$page['Rows'][$key]['catshops'] = (isset($goodsCatMap[$v['shopId']]))?implode(',',$goodsCatMap[$v['shopId']]):'';
|
||||
//$page['Rows'][$key]['areas']['areaName1'] = (isset($areaMap[$v['areaId']]['areaName1']))?$areaMap[$v['areaId']]['areaName1']:'';
|
||||
//$page['Rows'][$key]['areas']['areaName2'] = (isset($areaMap[$v['areaId']]['areaName2']))?$areaMap[$v['areaId']]['areaName2']:'';
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
/**
|
||||
* 获取卖家中心信息
|
||||
*/
|
||||
public function getShopSummary(){
|
||||
$shopId = (int)input('shopId',1);
|
||||
$shop = $this->alias('s')->join('__SHOP_SCORES__ cs','cs.shopId = s.shopId','left')
|
||||
->where(['s.shopId'=>$shopId,'dataFlag'=>1])
|
||||
->field('s.shopId,shopImg,shopName,shopkeeper,shopAddress,shopQQ,shopTel,serviceStartTime,serviceEndTime,isInvoice,invoiceRemarks,cs.*')
|
||||
->find();
|
||||
//评分
|
||||
$scores['totalScore'] = WSTScore($shop['totalScore'],$shop['totalUsers']);
|
||||
$scores['goodsScore'] = WSTScore($shop['goodsScore'],$shop['goodsUsers']);
|
||||
$scores['serviceScore'] = WSTScore($shop['serviceScore'],$shop['serviceUsers']);
|
||||
$scores['timeScore'] = WSTScore($shop['timeScore'],$shop['timeUsers']);
|
||||
WSTUnset($shop, 'totalUsers,goodsUsers,serviceUsers,timeUsers');
|
||||
$shop['scores'] = $scores;
|
||||
//认证
|
||||
$accreds = $this->shopAccreds($shopId);
|
||||
$shop['accreds'] = $accreds;
|
||||
return ['shop'=>$shop];
|
||||
}
|
||||
/**
|
||||
* 自营店铺楼层
|
||||
*/
|
||||
public function getFloorData(){
|
||||
$limit = (int)input('post.currPage');
|
||||
$cacheData = cache('WX_SHOP_FLOOR'.$limit);
|
||||
if($cacheData)return $cacheData;
|
||||
$rs = Db::name('shop_cats')->where(['dataFlag'=>1,'isShow'=>1,'parentId'=>0,'shopId'=>1])->field('catId,catName')->order('catSort asc')->limit($limit,1)->select();
|
||||
if($rs){
|
||||
$rs= $rs[0];
|
||||
$goods = Db::name('goods')->where('shopCatId1','=',$rs['catId'])->where(['dataFlag'=>1,'goodsStatus'=>1])->field('goodsId,goodsName,goodsImg,shopPrice,saleNum')->order('isHot desc')->limit(4)->select();
|
||||
$rs['goods'] = $goods;
|
||||
$rs['currPage'] = $limit;
|
||||
}
|
||||
cache('WX_SHOP_FLOOR'.$limit,$rs,86400);
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 根据订单id 获取店铺名称
|
||||
*/
|
||||
public function getShopName($oId){
|
||||
return $this->alias('s')
|
||||
->join('__ORDERS__ o',"s.shopId=o.shopId",'inner')
|
||||
->where("o.orderId=$oId")
|
||||
->value('s.shopName');
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加查看记数
|
||||
* @param [type] $rewardId [description]
|
||||
* @param [type] $userId [description]
|
||||
*/
|
||||
public function setRewardVisit($rewardId,$userId){
|
||||
$reward_num = Db::name('reward_num');
|
||||
$where['rewardId'] = $rewardId;
|
||||
$where['userId'] = $userId;
|
||||
if($reward_num->where($where)->find()){
|
||||
$reward_num->where($where)->setField('isVisit',1);
|
||||
}else{
|
||||
$data['rewardId'] = $rewardId;
|
||||
$data['userId'] = $userId;
|
||||
$data['isVisit'] = 1;
|
||||
$reward_num->insert($data);
|
||||
}
|
||||
Db::name('rewards')->where(['rewardId'=>$rewardId])->setInc('visitNum');
|
||||
}
|
||||
/**
|
||||
* 点赞记数
|
||||
* @param [type] $rewardId [description]
|
||||
* @param [type] $userId [description]
|
||||
*/
|
||||
public function setRewardLike($rewardId,$userId,$isLike){
|
||||
$reward_num = Db::name('reward_num');
|
||||
$where['rewardId'] = $rewardId;
|
||||
$where['userId'] = $userId;
|
||||
$dbIsLike = $reward_num->where($where)->value('isLike');
|
||||
if(isset($dbIsLike)){
|
||||
if($dbIsLike != $isLike){
|
||||
$reward_num->where($where)->setField('isLike',$isLike);
|
||||
if($isLike == 1){
|
||||
Db::name('rewards')->where(['rewardId'=>$rewardId])->setInc('likeNum');
|
||||
}else{
|
||||
Db::name('rewards')->where(['rewardId'=>$rewardId])->setDec('likeNum');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$data['rewardId'] = $rewardId;
|
||||
$data['userId'] = $userId;
|
||||
$data['isLike'] = $isLike;
|
||||
$reward_num->insert($data);
|
||||
if($isLike == 1){
|
||||
Db::name('rewards')->where(['rewardId'=>$rewardId])->setInc('likeNum');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* mark 20180518 by zl
|
||||
*获取商店特产省份
|
||||
*@param $shopId 商店id
|
||||
*
|
||||
*/
|
||||
public function getProv($shopId=1){
|
||||
$where['shopId'] = $shopId;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['provId'] = ['>','0'];
|
||||
$prov = Db::name('shop_cats')->distinct(true)->field('provId,provName')->where($where)->order('provId asc')->select();
|
||||
return $prov;
|
||||
}
|
||||
/**
|
||||
*获取商店特产省份
|
||||
*@param $shopId 商店id
|
||||
*@param $provId 省份id
|
||||
*/
|
||||
public function getShopCats($shopId=1,$provId=0){
|
||||
$where['shopId'] = $shopId;
|
||||
if($provId)$where['provId'] = $provId;
|
||||
$where['parentId'] = 0;
|
||||
$where['isShow'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$cats = Db::name('shop_cats')->where($where)
|
||||
->field('catId,catName,shopId,provId,provName,catImg')
|
||||
->order("catId asc")->select();
|
||||
return $cats;
|
||||
}
|
||||
/**
|
||||
*根据商店分类获取商品列表
|
||||
*@param $shopId 商店id
|
||||
*@param $shopCatId1 商店一级分类
|
||||
*/
|
||||
public function getGoodsByShopCats($shopId=1,$shopCatId1,$page=1){
|
||||
$cacheData = cache('APP_GOODS_BY_SHOPCAT_'.$shopId.'_'.$shopCatId1.'_'.$page);
|
||||
if($cacheData)return $cacheData;
|
||||
$where['shopId'] = $shopId;
|
||||
$where['shopCatId1'] = $shopCatId1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['isSale'] = 1;
|
||||
$where['goodsStatus'] = 1;
|
||||
$pagesize = 8;
|
||||
$offset = ($page-1)*$pagesize;
|
||||
$limit = "{$offset},{$pagesize}";
|
||||
$goods = Db::name('goods')->where($where)->limit($limit)->order("saleNum desc")->select();
|
||||
$list['goods'] = $goods;
|
||||
$list['page'] = $page;
|
||||
// $list = Db::name('goods')->where($where)->paginate($pagesize)->toArray();
|
||||
cache('APP_GOODS_BY_SHOPCAT_'.$shopId.'_'.$shopCatId1.'_'.$page,$list,600);
|
||||
return $list;
|
||||
}
|
||||
/**
|
||||
*获取首页热门特产榜单
|
||||
*
|
||||
*/
|
||||
public function getHotList($shopId=1){
|
||||
$where['shopId'] = $shopId;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['isShow'] = 1;
|
||||
$cat1 = cache('APP_HOT_LIST');
|
||||
if(!empty($cat1))return $cat1;
|
||||
//获取一级分类
|
||||
$cat1 = Db::name('shop_cats')->field('catId,catName')->where($where)->where(['isHot'=>1,'parentId'=>0])->order('catSort asc')->select();
|
||||
if(count($cat1)>0){
|
||||
foreach($cat1 as $k=>$v){
|
||||
//获取二级分类
|
||||
$cat2 = Db::name('shop_cats')->field('catId,catName')->where($where)->where(['parentId'=>$v['catId']])->select();
|
||||
if(count($cat2)>0){
|
||||
foreach($cat2 as $kk=>$vv){
|
||||
//获取二级分类下的商品
|
||||
$vv['goods'] = $this->getGoodsByCats($shopId,$v['catId'],$vv['catId']);
|
||||
if(isset($vv['goods'])){
|
||||
foreach ($vv['goods'] as $key => $value) {
|
||||
$vv['goods'][$key]['goodsImg'] = WSTImg($value['goodsImg'],2);
|
||||
}
|
||||
}
|
||||
$cat1[$k]['cat2'][] = $vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cache('APP_HOT_LIST',$cat1,600);
|
||||
return $cat1;
|
||||
}
|
||||
//根据分类获取商品数据
|
||||
public function getGoodsByCats($shopId=1,$catId1,$catId2){
|
||||
$where['dataFlag'] = 1;
|
||||
$where['goodsStatus'] = 1;
|
||||
$where['isSale'] = 1;
|
||||
$where['shopId'] = $shopId;
|
||||
$where['shopCatId1'] = $catId1;
|
||||
$where['shopCatId2'] = $catId2;
|
||||
|
||||
$goods = Db::name('goods')->field('goodsId,goodsName,goodsImg,shopPrice')->where($where)->order('visitNum desc')->limit(2)->select();
|
||||
return $goods;
|
||||
}
|
||||
/**
|
||||
* end
|
||||
*/
|
||||
}
|
83
hyhproject/app/model/Tags.php
Executable file
83
hyhproject/app/model/Tags.php
Executable file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Tags as CTags;
|
||||
use think\Db;
|
||||
/**
|
||||
* 标签业务处理类
|
||||
*/
|
||||
class Tags extends CTags{
|
||||
|
||||
/**
|
||||
* 获取最新文章
|
||||
*/
|
||||
public function newArticle(){
|
||||
// $rs = Db::name('articles')->alias('a')->field('a.articleId,a.articleTitle,a.coverImg,a.createTime')->join('article_cats ac','a.catId=ac.catId','inner')
|
||||
// ->where('ac.catType=0 and ac.parentId=8 and a.dataFlag=1 and ac.isShow=1')->order('a.createTime','desc')->cache(true,86400)->paginate(input('pagesize/d'))->toArray();
|
||||
//return $rs;
|
||||
$page = input('page');
|
||||
$cacheData = cache('TAG_NEW_ARTICLES'.$page);
|
||||
if($cacheData)return $cacheData;
|
||||
$rs = Db::name('articles')->alias('a')->field('a.articleId,a.articleTitle,a.coverImg,a.createTime')->join('article_cats ac','a.catId=ac.catId','inner')
|
||||
->where('ac.catType=0 and ac.parentId<>7 and a.dataFlag=1 and ac.isShow=1 and a.isShow=1 and ac.dataFlag=1')->order('a.createTime','desc')->paginate(input('pagesize/d'))->toArray();
|
||||
cache('TAG_NEW_ARTICLES'.$page,$rs,86400);
|
||||
|
||||
return $rs;
|
||||
}
|
||||
//添加显示会员快报 make cheng 20180227
|
||||
public function showArticle(){
|
||||
$articleId = input('articleId/d');
|
||||
$article = Db::name('articles')->where('articleId', $articleId)->field('articleTitle,articleContent,createTime')->find();
|
||||
$article['articleContent']=htmlspecialchars_decode($article['articleContent']);
|
||||
return WSTReturn('', 1, $article);
|
||||
}
|
||||
|
||||
/**
|
||||
* 桔子头条分类
|
||||
*/
|
||||
|
||||
public function orangeType(){
|
||||
//$catName= '商城快讯';
|
||||
$orange = [];
|
||||
//$catId =(int)Db::name('article_cats')->where(['catName'=>$catName,'dataFlag'=>1])->value('catId');
|
||||
$catId = 8;
|
||||
if($catId){
|
||||
$orange = Db::name('article_cats')->where(['parentId'=>$catId,'dataFlag'=>1])->select();
|
||||
}
|
||||
return $orange;
|
||||
// dump($frontPage);die;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $catName
|
||||
* @return array
|
||||
* 桔子头条文章
|
||||
*/
|
||||
public function clog($catId){
|
||||
// $catId = input('catId');
|
||||
// echo $catId;die;
|
||||
$pageSize = (int)input('pageSize/d',10);
|
||||
$where = array();
|
||||
$where['isShow'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['catId'] = $catId;
|
||||
// var_dump($where);die;
|
||||
$clog = Db::name('articles')->where($where)->paginate($pageSize)->toArray();
|
||||
foreach($clog['Rows'] as &$v){
|
||||
$v['coverImg'] = WSTImg($v['coverImg'],3);
|
||||
$v['articleContent']=htmlspecialchars($v['articleContent']);
|
||||
}
|
||||
return $clog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 桔子头条文章详情
|
||||
*/
|
||||
public function detail($articleId){
|
||||
$detail = Db::name('articles')->where('articleId',$articleId)->find();
|
||||
// foreach($detail as &$v){
|
||||
// $v['coverImg'] = WSTImg($v['coverImg'],2);
|
||||
// }
|
||||
$detail['articleContent']=htmlspecialchars_decode($detail['articleContent']);
|
||||
return $detail;
|
||||
}
|
||||
}
|
46
hyhproject/app/model/Users - ╕▒▒╛.php
Executable file
46
hyhproject/app/model/Users - ╕▒▒╛.php
Executable file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Users as CUsers;
|
||||
use Think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 用户类
|
||||
*/
|
||||
class Users extends CUsers{
|
||||
/**
|
||||
* 验证用户支付密码
|
||||
*/
|
||||
function checkPayPwd(){
|
||||
$payPwd = input('payPwd');
|
||||
$decrypt_data = WSTRSA($payPwd);
|
||||
if($decrypt_data['status']==1){
|
||||
$payPwd = $decrypt_data['data'];
|
||||
}else{
|
||||
return jsonReturn('验证失败');
|
||||
}
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$rs = $this->field('payPwd,loginSecret')->find($userId);
|
||||
if($rs['payPwd']==md5($payPwd.$rs['loginSecret'])){
|
||||
return jsonReturn('',1);
|
||||
}
|
||||
return jsonReturn('支付密码错误',-1);
|
||||
}
|
||||
/**
|
||||
* 获取首页数据
|
||||
* @param [type] $userId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function getIndex($userId){
|
||||
|
||||
}
|
||||
function getUserInfo($userId,$field){
|
||||
return $this->where(['userId'=>$userId])->field($field)->find();
|
||||
}
|
||||
function appLogOut($userId){
|
||||
$this->where(['userId'=>$userId])->setField('token','');
|
||||
session('WST_USER',null);
|
||||
//setcookie("loginPwd", null);
|
||||
session('WST_MO_WlADDRESS',null);
|
||||
}
|
||||
|
||||
}
|
48
hyhproject/app/model/Users.php
Executable file
48
hyhproject/app/model/Users.php
Executable file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace wstmart\app\model;
|
||||
use wstmart\common\model\Users as CUsers;
|
||||
use Think\Db;
|
||||
|
||||
/**
|
||||
* ============================================================================
|
||||
* 用户类
|
||||
*/
|
||||
class Users extends CUsers{
|
||||
/**
|
||||
* 验证用户支付密码
|
||||
*/
|
||||
function checkPayPwd(){
|
||||
$payPwd = input('payPwd');
|
||||
$decrypt_data = WSTRSA($payPwd);
|
||||
if($decrypt_data['status']==1){
|
||||
$payPwd = $decrypt_data['data'];
|
||||
}else{
|
||||
return jsonReturn('验证失败');
|
||||
}
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$rs = $this->field('payPwd,loginSecret')->find($userId);
|
||||
if($rs['payPwd']==md5($payPwd.$rs['loginSecret'])){
|
||||
return jsonReturn('',1);
|
||||
}
|
||||
return jsonReturn('支付密码错误',-1);
|
||||
}
|
||||
/**
|
||||
* 获取首页数据
|
||||
* @param [type] $userId [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function getIndex($userId){
|
||||
|
||||
}
|
||||
function getUserInfo($userId,$field){
|
||||
return $this->where(['userId'=>$userId])->field($field)->find();
|
||||
}
|
||||
function appLogOut($userId){
|
||||
$this->where(['userId'=>$userId])->setField('token','');
|
||||
session('WST_USER',null);
|
||||
//setcookie("loginPwd", null);
|
||||
session('WST_MO_WlADDRESS',null);
|
||||
}
|
||||
|
||||
|
||||
}
|
24
hyhproject/app/validate/UserAddress.php
Executable file
24
hyhproject/app/validate/UserAddress.php
Executable file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace wstmart\app\validate;
|
||||
use think\Validate;
|
||||
/**
|
||||
* ============================================================================
|
||||
* WSTMart开源商城
|
||||
* 官网地址:http://www.wstmall.com
|
||||
* 联系QQ:707563272
|
||||
* ============================================================================
|
||||
* 用户地址验证器
|
||||
*/
|
||||
class UserAddress extends Validate{
|
||||
protected $rule = [
|
||||
['userName' ,'require','请输入联系名称'],
|
||||
['userPhone' ,'require','请输入手机号码'],
|
||||
['areaId' ,'require','请选择完整地址'],
|
||||
['userAddress' ,'require','请输入详细地址']
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['userName','userPhone','areaId','userAddress'],
|
||||
'edit' => ['userName','userPhone','areaId','userAddress']
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user