123 行
4.3 KiB
PHP
可执行文件
123 行
4.3 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Vip\Controller;
|
|
|
|
use Think\Controller;
|
|
|
|
//[1.3.86]
|
|
class ScoreMallController extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
$user = session('userinfo');
|
|
$map['pm.merchant_id'] = $user['merchantid'];
|
|
$map['pm.m_status'] = 1;
|
|
$map['pm.status'] = 1;
|
|
$map['m.id'] = $user['merchantid'];
|
|
$map['p.status'] = 1;
|
|
$map['pa.a_status'] = 1;
|
|
$map['p.plug_name'] = '积分商城';
|
|
$plug = M('plug_merchant as pm')
|
|
->join('ls_plug as p on p.id=pm.plug_id')
|
|
->join('ls_plug_agent as pa on pa.plug_id=p.id')
|
|
->join('ls_retail_merchant as m on m.agentid=pa.agent_id')
|
|
->where($map)
|
|
->find();
|
|
if (empty($plug)) {
|
|
$this->tipsMsg(0, '商家未开启积分商城');
|
|
}
|
|
$merchantid = $user['merchantid'];
|
|
$list = M("retail_scoremall")->where(array('merchantid' => $merchantid, 'status' => 1))->select();
|
|
$ImageGalleryModel = D('ImageGallery');
|
|
foreach ($list as &$value){
|
|
$value['image'] = $ImageGalleryModel->getFieldPath(array('id' => $value['image_id']));
|
|
}
|
|
$ban = M("retail_score_tempbanner")->where(array('pid' => $merchantid, 'status' => 1))->select();
|
|
$integral = $user['integral'];
|
|
$this->assign("ban", $ban);
|
|
$this->assign('list', $list);
|
|
$this->assign('integral', $integral);
|
|
$this->display();
|
|
}
|
|
|
|
public function me()
|
|
{
|
|
$user = session('userinfo');
|
|
$this->assign('user', $user);
|
|
$this->display();
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
$user = session('userinfo');
|
|
$userid = $user['id'];
|
|
$merchantid = $user['merchantid'];
|
|
$list = M("retail_score_mall_exchange as a")
|
|
->join("ls_retail_scoremall as b on b.id = a.shopid")
|
|
->where(array('a.vid' => $userid, 'a.merchantid' => $merchantid, 'a.status' => array('in', '1,2'), 'a.state' => 1))
|
|
->order('a.status asc,a.id desc')
|
|
->field("a.*,b.name,b.price,b.image_id,b.type,b.integral")
|
|
->select();
|
|
$ImageGalleryModel = D('ImageGallery');
|
|
foreach ($list as &$val){
|
|
$val['image'] = $ImageGalleryModel->getFieldPath(array('id' => $val['image_id']));
|
|
}
|
|
$this->assign('list', $list);
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* 2019-11-16
|
|
* 积分商城会员余额支付或只付积分
|
|
*/
|
|
public function scoreMallVipPay()
|
|
{
|
|
$score_exchange_id = I('post.score_exchange_id');//购买记录id
|
|
$password = I('post.password');
|
|
$vip = session('userinfo');
|
|
$vid = session('vid');
|
|
if (empty($score_exchange_id) || empty($vip) || empty($password)) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = '缺少参数';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$VipModel = D('RetailVip');
|
|
if (!checkPassword($vip[$VipModel::PASSWORD], $password, $vip[$VipModel::ADD_TIME])) {
|
|
$res['status'] = 2;
|
|
$res['msg'] = '会员支付密码错误';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$merchant_id = $vip[$VipModel::MERCHANT_ID];
|
|
$SMExchangeModel = D('RetailScoreMallExchange');
|
|
$eMap = array(
|
|
$SMExchangeModel::ID => $score_exchange_id,
|
|
$SMExchangeModel::VID => $vid,
|
|
$SMExchangeModel::MERCHANT_ID => $merchant_id,
|
|
$SMExchangeModel::STATUS => 1,
|
|
$SMExchangeModel::STATE => 0,
|
|
);
|
|
//判断订单是否存在
|
|
$changeOrder = $SMExchangeModel->getFind($eMap);
|
|
if (empty($changeOrder)) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = '操作有误';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$result = A('PayApi/ScoreMall')->orderSuccess($changeOrder);
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
$id = I('post.sid');
|
|
$list = M("retail_score_mall_exchange")->where(array('id' => $id))->save(array('status' => 2));
|
|
if ($list) {
|
|
$res['status'] = 1;
|
|
$res['msg'] = "领取成功";
|
|
} else {
|
|
$res['status'] = 0;
|
|
$res['msg'] = "领取失败";
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |