文件
mashangyoujiu/Application/Retail/Controller/UuerrandsController.class.php

293 行
10 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Retail\Controller;
use Common\Model\RetailStoreModel;
use Common\Model\RetailUuMerchantModel;
use Retail\Business\UU;
use Retail\Model\UuModel;
//[1.7.90]
class UuerrandsController extends BaseController
{
public function index()
{
$arr = array(
'getopenid' => '/index.php/Retail/Uuerrands/getopenid',
'balance' => '/index.php/Retail/Uuerrands/balance',
'recharge' => '/index.php/Retail/Uuerrands/recharge',
);
$authArr = checkFunction($arr);
$this->assign('authArr', $authArr);
$this->display();
}
//uu跑腿商家信息
public function getmerchantinfo()
{
$content = M('retail_uu_merchant')->where(array('merchantid' => $this->merchant_id))->select();
$count = M('retail_uu_merchant')->where(array('merchantid' => $this->merchant_id))->count();
if ($content) {
foreach ($content as &$val) {
$val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
}
}
$res['code'] = 0;
$res['msg'] = '';
$res['data'] = $content;
$res['count'] = $count;
$this->ajaxReturn($res);
}
//获取验证码
public function getcode()
{
$phone = I('post.phone');
if (empty($phone)) {
$this->ajaxReturn(['status' => 0, 'msg' => '请输入手机号']);
}
$info = $this->getinfo();
$data['user_mobile'] = $phone;
$data['user_ip'] = $info['uu_ip'];
$data['appid'] = $info['uu_appid'];
$appkey = $info['uu_appkey'];
if (empty($data['user_ip']) || empty($data['appid']) || empty($appkey)) {
$this->ajaxReturn(['status' => 0, 'msg' => '请完善合伙人UU跑腿设置']);
}
$content = A('Uudelivery')->getcode($data, $appkey);
$content = json_decode($content, true);
if ($content['return_code'] == 'ok') {
$res = ['status' => 1, 'msg' => $content['return_msg']];
} else {
$res = ['status' => 0, 'msg' => $content['return_msg']];
}
$this->ajaxReturn($res);
}
//获取openid
public function getopenid()
{
$post = I('post.');
$phone = $post['phone'];
$code = $post['pass'];
$city_name = $post['city_name'];
$county_name = $post['county_name'];
if (empty($phone) || empty($city_name) || empty($code)) {
$this->ajaxReturn(['status' => 0, 'msg' => '参数错误']);
}
$info = $this->getinfo();
$data['user_mobile'] = $phone;
$data['validate_code'] = $code;
$data['city_name'] = $city_name;
if (!empty($county_name)) {
$data['county_name'] = $county_name;
}
$data['reg_ip'] = $info['uu_ip'];
$data['appid'] = $info['uu_appid'];
$appkey = $info['uu_appkey'];
if (empty($data['reg_ip']) || empty($data['appid']) || empty($appkey)) {
$this->ajaxReturn(['status' => 0, 'msg' => '请完善合伙人UU跑腿设置']);
}
$content = A('Uudelivery')->getopenid($data, $appkey);
$content = json_decode($content, true);
if ($content['return_code'] == 'ok') {
$text['phone'] = $phone;
$text['openid'] = $content['openid'];
$text['city_name'] = $city_name;
$text['county_name'] = $county_name;
$text['addtime'] = time();
$text['merchantid'] = $this->merchant_id;
$RetailUuMerchantModel = new RetailUuMerchantModel();
$merchant = $RetailUuMerchantModel->getFind(['merchantid' => $this->merchant_id]);
if ($merchant) {
$add = $RetailUuMerchantModel->updateOrder(['merchantid' => $this->merchant_id], $text);
} else {
$add = $RetailUuMerchantModel->addOrder($text);
}
if ($add) {
$res['status'] = 1;
$res['msg'] = '您的openid为' . $content['openid'];
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST); //请求参数 json数据
$desc = '绑定UU账号获取openid'; //操作行为描述
action_log($source, $type, $request_data, $desc);
//end
} else {
$res['status'] = 0;
$res['msg'] = 'openid获取成功修改数据表失败';
}
} else {
$res['status'] = 0;
$res['msg'] = $content['return_msg'];
}
$this->ajaxReturn($res);
}
//余额查询
public function balance()
{
$openid = I('get.openid');
$info = $this->getinfo();
$data['user_openid'] = $openid;
$data['openid'] = $openid;
$data['appid'] = $info['uu_appid'];
$appkey = $info['uu_appkey'];
$content = A('Uudelivery')->getbalance($data, $appkey);
$content = json_decode($content, true);
if ($content['return_code'] == 'ok') {
$this->assign('accountmoney', $content['AccountMoney']);
$this->assign('lockedmoney', $content['LockedMoney']);
} else {
$this->assign('accountmoney', '参数错误');
$this->assign('lockedmoney', '参数错误');
}
$this->display();
}
//充值
public function recharge()
{
$openid = I('post.openid');
$info = $this->getinfo();
$data['user_openid'] = $openid;
$data['openid'] = $openid;
$data['appid'] = $info['uu_appid'];
$appkey = $info['uu_appkey'];
$content = A('Uudelivery')->recharge($data, $appkey);
$content = json_decode($content, true);
if ($content['return_code'] == 'ok' && $content['appid'] == $data['appid']) {
$res['status'] = 1;
$res['url'] = $content['RechargeURL'];
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST); //请求参数 json数据
$desc = 'UU跑腿充值操作'; //操作行为描述
action_log($source, $type, $request_data, $desc);
//end
} else {
$res['status'] = 0;
$res['msg'] = $content['return_msg'];
}
$this->ajaxReturn($res);
}
//获取ip地址与合伙人appid
private function getinfo()
{
$user = session("ls_userinfo");
$info = M('retail_da_developer')->where(array('partnerid' => $user['partnerid']))->find();
return $info;
}
//配送记录
public function deliveryrecord_uu()
{
$this->display();
}
//配送表
public function getMerDeliveryList()
{
$UuClass = new UU();
$param = I('post.');
$param['merchant_id'] = $this->merchant_id;
$this->ajaxReturn($UuClass->getUuDeliveryList($param));
}
//搜索统计
public function getMerDeliveryTotal()
{
$UuClass = new UU();
$param = I('post.');
$param['merchant_id'] = $this->merchant_id;
$this->ajaxReturn($UuClass->getUuDeliveryTotal($param));
}
//导出UU配送记录
public function merExport()
{
$UuClass = new UU();
$param = I('get.');
$param['merchant_id'] = $this->merchant_id;
$param['is_export'] = 1;
$result = $UuClass->getUuDeliveryList($param);
$filename = "UU配送记录";
$arr = [
['index', '序号'],
['order_id', '门店订单号'],
['ordercode', 'UU订单号'],
['store_name', '门店名称'],
['add_time', '添加时间'],
['driver_name', '配送员姓名'],
['driver_jobnum', '配送员工号'],
['driver_mobile', '配送员手机号'],
['distance', '配送距离(米)'],
['total_money', '配送费'],
['total_priceoff', '总优惠金额'],
['need_paymoney', '实际配送费'],
['order_status', '订单状态'],
['order_type', '订单类型'],
];
$str = "导出时间" . date('Y-m-d H:i:s', time());
getExcel($filename, $arr, $result['data']['list'], $str);
}
public function storerecord()
{
$this->display();
}
//门店记录
public function getStoreDeliveryList()
{
$UuClass = new UU();
$param = I('post.');
$param['merchant_id'] = $this->merchant_id;
$param['store_id'] = $this->store_id;
$this->ajaxReturn($UuClass->getUuDeliveryList($param));
}
//门店搜索统计
public function getStoreDeliveryTotal()
{
$UuClass = new UU();
$param = I('post.');
$param['merchant_id'] = $this->merchant_id;
$param['store_id'] = $this->store_id;
$this->ajaxReturn($UuClass->getUuDeliveryTotal($param));
}
//门店导出
public function storeExport()
{
$UuClass = new UU();
$param = I('get.');
$param['merchant_id'] = $this->merchant_id;
$param['store_id'] = $this->store_id;
$param['is_export'] = 1;
$result = $UuClass->getUuDeliveryList($param);
$filename = "UU配送记录";
$arr = [
['index', '序号'],
['order_id', '门店订单号'],
['ordercode', 'UU订单号'],
['store_name', '门店名称'],
['add_time', '添加时间'],
['driver_name', '配送员姓名'],
['driver_jobnum', '配送员工号'],
['driver_mobile', '配送员手机号'],
['distance', '配送距离(米)'],
['total_money', '配送费'],
['total_priceoff', '总优惠金额'],
['need_paymoney', '实际配送费'],
['order_status', '订单状态'],
['order_type', '订单类型'],
];
$str = "导出时间" . date('Y-m-d H:i:s', time());
getExcel($filename, $arr, $result['data']['list'], $str);
}
}