init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
|
||||
namespace Retail\Controller;
|
||||
|
||||
use Common\Business\TemplatePushNews;
|
||||
use Think\Controller;
|
||||
|
||||
//[1.5.66]
|
||||
class XcxMarkController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$arr = array(
|
||||
'editMark' => '/index.php/Retail/XcxMark/editMark',
|
||||
);
|
||||
$authArr = checkFunction($arr);
|
||||
$this->assign('authArr', $authArr);
|
||||
$typeArr = array(
|
||||
array(
|
||||
'k' => 1,
|
||||
'v' => '自提通知',
|
||||
),
|
||||
array(
|
||||
'k' => 2,
|
||||
'v' => '发货通知',
|
||||
),
|
||||
array(
|
||||
'k' => 3,
|
||||
'v' => '分期到账',
|
||||
)
|
||||
);
|
||||
$fieldsList = array(
|
||||
//自提
|
||||
'1' => array(
|
||||
array('field' => 'store_name', 'name' => '门店名称'), //门店名称
|
||||
array('field' => 'order_no', 'name' => '订单号'), //订单号
|
||||
array('field' => 'pick_code', 'name' => '提货码'), //提货码
|
||||
array('field' => 'price', 'name' => '交易金额'), //订单金额
|
||||
array('field' => 'add_time', 'name' => '购买时间'), //购买时间
|
||||
array('field' => 'goods_name', 'name' => '商品名称'), //商品名称
|
||||
array('field' => 'pick_time', 'name' => '提货时间'), //提货时间
|
||||
array('field' => 'store_address', 'name' => '商家地址'), //商家地址
|
||||
array('field' => 'store_phone', 'name' => '商家电话'), //商家电话
|
||||
array('field' => 'user_phone', 'name' => '客户电话'), //客户电话
|
||||
array('field' => 'username', 'name' => '联系人'), //客户姓名
|
||||
array('field' => 'user_remark', 'name' => '客户备注'), //客户备注
|
||||
array('field' => 'order_type', 'name' => '订单类型'), //订单类型
|
||||
),
|
||||
//发货
|
||||
'2' => array(
|
||||
array('field' => 'store_name', 'name' => '门店名称'), //门店名称
|
||||
array('field' => 'delivery_type', 'name' => '配送方式'), //配送方式
|
||||
array('field' => 'delivery_time', 'name' => '发货时间'), //发货时间
|
||||
array('field' => 'order_no', 'name' => '订单号'), //订单号
|
||||
array('field' => 'user_address', 'name' => '收货地址'), //收货地址
|
||||
array('field' => 'user_phone', 'name' => '客户电话'), //客户电话
|
||||
array('field' => 'username', 'name' => '收货人'), //客户姓名
|
||||
array('field' => 'price', 'name' => '交易金额'), //订单金额
|
||||
array('field' => 'add_time', 'name' => '购买时间'), //购买时间
|
||||
array('field' => 'goods_name', 'name' => '商品名称'), //商品名称
|
||||
array('field' => 'store_address', 'name' => '商家地址'), //商家地址
|
||||
array('field' => 'store_phone', 'name' => '商家电话'), //商家电话
|
||||
array('field' => 'user_remark', 'name' => '客户备注'), //客户备注
|
||||
array('field' => 'order_type', 'name' => '订单类型'), //订单类型
|
||||
),
|
||||
//分期到账
|
||||
'3' => array(
|
||||
array('field' => 'aging_money', 'name' => '到账金额'),
|
||||
array('field' => 'has_arrive', 'name' => '到账期数'),
|
||||
array('field' => 'aging_date', 'name' => '到账时间'),
|
||||
array('field' => 'un_arrive', 'name' => '剩余期数'),
|
||||
),
|
||||
);
|
||||
$this->assign('typeArr', json_encode($typeArr));
|
||||
$this->assign('fieldsList', json_encode($fieldsList));
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function getModelList()
|
||||
{
|
||||
$user = session("merchant_userinfo");
|
||||
$XcxMarkModel = D('XcxMark');
|
||||
$merchant_id = $user['merchantid'];
|
||||
$map = array(
|
||||
$XcxMarkModel::MERCHANT_ID => $merchant_id,
|
||||
);
|
||||
$list = $XcxMarkModel->getSelect($map);
|
||||
foreach ($list as &$val) {
|
||||
$val['fields_json'] = json_decode($val['fields_json'], true);
|
||||
if (!$val['fields_json']) {
|
||||
$val['fields_json'] = array(
|
||||
"first" => "",
|
||||
"keyword_list" => array(),
|
||||
"remark" => "",
|
||||
"title" => "",
|
||||
);
|
||||
}
|
||||
$val['type'] = intval($val['type']);
|
||||
switch ($val['type']) {
|
||||
case 1:
|
||||
$val['type_name'] = '自提通知';
|
||||
break;
|
||||
case 2:
|
||||
$val['type_name'] = '发货通知';
|
||||
break;
|
||||
case 3:
|
||||
$val['type_name'] = '分期到账';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '获取成功';
|
||||
$res['template_list'] = $list;
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
|
||||
//保存设置
|
||||
public function updateSet()
|
||||
{
|
||||
$XcxMarkModel = D('XcxMark');
|
||||
$merchant_id = session('merchant_userinfo')['id'];
|
||||
$content = I('post.');
|
||||
if (!$content['model_id'] || !$content['type'] || !$content['fields_json']) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '参数缺失';
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
$fields_json = $content['fields_json'];
|
||||
if (!$fields_json['keyword_list']) {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '请添加字段';
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
foreach ($fields_json['keyword_list'] as $value) {
|
||||
if (empty($value['key'])) {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '请输入字段键名';
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
if (empty($value['field'])) {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '请选择字段键值';
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($content['id'])) {
|
||||
$map['id'] = array('neq', $content['id']);
|
||||
}
|
||||
$map['model_id'] = trim($content['model_id']);
|
||||
$info = $XcxMarkModel->getFind($map);
|
||||
if ($info) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '已存在该模板ID';
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
$item = array(
|
||||
$XcxMarkModel::MERCHANT_ID => $merchant_id,
|
||||
$XcxMarkModel::MODEL_ID => trim($content['model_id']),
|
||||
$XcxMarkModel::STATUS => $content['status'],
|
||||
$XcxMarkModel::TYPE => $content['type'],
|
||||
$XcxMarkModel::FIELDS_JSON => json_encode($content['fields_json']),
|
||||
);
|
||||
if (!empty($content['id'])) {
|
||||
$res = $XcxMarkModel->updateOrder(array('id' => $content['id']), $item);
|
||||
} else {
|
||||
$res = $XcxMarkModel->addOrder($item);
|
||||
$content['id'] = $res;
|
||||
}
|
||||
if ($res) {
|
||||
if ($content['status'] == 1) {
|
||||
$this->saveTemplateStatus($content);
|
||||
}
|
||||
$result['id'] = $content['id'];
|
||||
$result['status'] = 1;
|
||||
$result['msg'] = '保存成功';
|
||||
//操作日志记录
|
||||
$source = 0;//请求来源: 0pc系统 1小助手
|
||||
$type = 3;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||||
$request_data = json_encode($_POST);//请求参数 json数据
|
||||
$desc = '小程序模板-编辑保存设置';//操作行为描述
|
||||
action_log($source, $type, $request_data, $desc);
|
||||
//end
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '暂无修改';
|
||||
}
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 该变其他模板状态
|
||||
*/
|
||||
public function saveTemplateStatus($content)
|
||||
{
|
||||
$XcxMarkModel = D('XcxMark');
|
||||
$map = array(
|
||||
'merchant_id' => session('merchant_userinfo')['id'],
|
||||
'type' => $content['type'],
|
||||
'id' => array('neq', $content['id'])
|
||||
);
|
||||
$XcxMarkModel->updateOrder($map, array('status' => 0));
|
||||
}
|
||||
|
||||
public function deleteTemplate()
|
||||
{
|
||||
$id = I('post.id');
|
||||
if (empty($id)) {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '缺少参数';
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
$merchant_id = session("merchant_userinfo")['id'];
|
||||
$XcxMarkModel = D('XcxMark');
|
||||
$map = array(
|
||||
$XcxMarkModel::MERCHANT_ID => $merchant_id,
|
||||
$XcxMarkModel::ID => $id,
|
||||
);
|
||||
$del = $XcxMarkModel->deleteOrder($map);
|
||||
if ($del) {
|
||||
$result['status'] = 1;
|
||||
$result['msg'] = '删除成功';
|
||||
//操作日志记录
|
||||
$source = 0;//请求来源: 0pc系统 1小助手
|
||||
$type = 3;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||||
$request_data = json_encode($_POST);//请求参数 json数据
|
||||
$desc = '小程序模板-删除模板';//操作行为描述
|
||||
action_log($source, $type, $request_data, $desc);
|
||||
//end
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '删除失败';
|
||||
}
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 开关
|
||||
*/
|
||||
public function saveState()
|
||||
{
|
||||
$merchant_id = session("merchant_userinfo")['id'];
|
||||
$XcxMarkModel = D('XcxMark');
|
||||
$content = I("post.");
|
||||
if (!$content['id']) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '请先保存';
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
$save = $XcxMarkModel->updateOrder(array('id' => $content['id']), array('status' => $content['status']));
|
||||
if ($save) {
|
||||
if ($content['status'] == 1) {
|
||||
$this->saveTemplateStatus($content);
|
||||
}
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '操作成功';
|
||||
//操作日志记录
|
||||
$source = 0;//请求来源: 0pc系统 1小助手
|
||||
$type = 3;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||||
$request_data = json_encode($_POST);//请求参数 json数据
|
||||
$desc = '小程序模板-修改模板状态';//操作行为描述
|
||||
action_log($source, $type, $request_data, $desc);
|
||||
//end
|
||||
} else {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '暂无修改';
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
|
||||
//消息推送
|
||||
public function pushNews()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['merchant_id'] = $this->merchant_id;
|
||||
$TemplateClass = new TemplatePushNews();
|
||||
$result = $TemplateClass->xcxPush($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户