作者 王晓刚
1 个管道 的构建 通过 耗费 0 秒

合并分支 'wangxiaogang' 到 'master'

Wangxiaogang



查看合并请求 !2
... ... @@ -232,5 +232,24 @@ $configs = [
'cmf_default_theme' => 'simpleboot3',
'cmf_admin_theme_path' => 'themes/',
'cmf_admin_default_theme' => 'admin_simpleboot3',
//快递鸟参数配置
'bird'=>[
//正式
//'EBusinessID' => '1472267',//电商ID
//'AppKey' => 'cc8314fd-0381-4e37-ad17-239287f1d8d2',//AppKey
//测试
'EBusinessID' => 'test1472267',
'AppKey' => 'f84c7071-a6c7-48ce-8fe0-11b719d88a1d',
],
//快递鸟预约取件接口寄件人参数
'sender'=>[
'Name' => "李先生",
'Mobile' => "18888888888",
'ProvinceName' => "河北省",
'CityName' => "石家庄市",
'ExpAreaName' => "新华区",
'Address' => "学府路121号",
],
];
return array_merge($configs, $runtimeConfig,$wechatConfig);
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/6/7
* Time: 9:25
*/
namespace app\portal\controller;
use app\portal\model\IndentModel;
use cmf\controller\HomeBaseController;
use think\Db;
class BirdController extends HomeBaseController
{
public function createOrder($indent_id = null)
{
if(empty($indent_id)){
$this->error('缺少必要参数','','','');
}
$where['id'] = ['eq',$indent_id];
$indentModel = new IndentModel();
$indent = $indentModel->findData($where);
if(empty($indent)){
$this->error('未查询到该订单','','','');
}
if($indent['state'] != 2){
$this->error('该订单不是待发货状态','','','');
}
$bird = config('bird');
//电商ID
defined('EBusinessID') or define('EBusinessID', $bird['EBusinessID']);
//电商加密私钥,快递鸟提供,注意保管,不要泄漏
defined('AppKey') or define('AppKey', $bird['AppKey']);
//请求url,接口正式地址:http://api.kdniao.com/api/eorderservice 测试环境地址:http://testapi.kdniao.com:8081/api/oorderservice
defined('ReqURL') or define('ReqURL', 'http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json');
//构造在线下单提交信息
$eorder = [];
$eorder["ShipperCode"] = "SF";
$eorder["OrderCode"] = "PM2016050789471";
$eorder["PayType"] = 1;
$eorder["ExpType"] = 1;
$eorder['IsNotice'] = 0;
$sender = config('sender');
// $sender["Name"] = "李先生";
// $sender["Mobile"] = "18888888888";
// $sender["ProvinceName"] = "李先生";
// $sender["CityName"] = "深圳市";
// $sender["ExpAreaName"] = "福田区";
// $sender["Address"] = "赛格广场5401AB";
$receiver = [];
$receiver["Name"] = "李先生";
$receiver["Mobile"] = "18888888888";
$receiver["ProvinceName"] = "李先生";
$receiver["CityName"] = "深圳市";
$receiver["ExpAreaName"] = "福田区";
$receiver["Address"] = "赛格广场5401AB";
$commodityOne = [];
$commodityOne["GoodsName"] = "书";
$commodity = [];
$commodity[] = $commodityOne;
$eorder["Sender"] = $sender;
$eorder["Receiver"] = $receiver;
$eorder["Commodity"] = $commodity;
//调用在线下单
$jsonParam = json_encode($eorder, JSON_UNESCAPED_UNICODE);
$jsonResult = $this->submitOOrder($jsonParam);
//解析在线下单返回结果
$result = json_decode($jsonResult, true);
if ($result["ResultCode"] == "100") {
return $result['Order']['LogisticCode'];//返回快递单号
} else {
return $result['Reason'];
}
}
/**
* Json方式 提交在线下单
* @param $requestData
* @return url响应返回的html
*/
function submitOOrder($requestData)
{
$datas = array(
'EBusinessID' => EBusinessID,
'RequestType' => '1001',
'RequestData' => urlencode($requestData),
'DataType' => '2',
);
$datas['DataSign'] = $this->encrypt($requestData, AppKey);
$result = $this->sendPost(ReqURL, $datas);
//根据公司业务处理返回的信息......
return $result;
}
/**
* post提交数据
* @param string $url 请求Url
* @param array $datas 提交的数据
* @return url响应返回的html
*/
function sendPost($url, $datas)
{
$temps = array();
foreach ($datas as $key => $value) {
$temps[] = sprintf('%s=%s', $key, $value);
}
$post_data = implode('&', $temps);
$url_info = parse_url($url);
$httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
$httpheader .= "Host:" . $url_info['host'] . "\r\n";
$httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
$httpheader .= "Content-Length:" . strlen($post_data) . "\r\n";
$httpheader .= "Connection:close\r\n\r\n";
$httpheader .= $post_data;
$fd = fsockopen($url_info['host'], $url_info['port']);
fwrite($fd, $httpheader);
$gets = "";
$headerFlag = true;
while (!feof($fd)) {
if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
break;
}
}
while (!feof($fd)) {
$gets .= fread($fd, 128);
}
fclose($fd);
return $gets;
}
/**
* 电商Sign签名生成
* @param data 内容
* @param appkey Appkey
* @return DataSign签名
*/
function encrypt($data, $appkey)
{
return urlencode(base64_encode(md5($data . $appkey)));
}
}
\ No newline at end of file
... ...
... ... @@ -9,20 +9,78 @@
namespace app\portal\controller;
use app\portal\model\OrderModel;
use app\portal\model\IndentGoodsModel;
use app\portal\model\IndentModel;
use cmf\controller\WeChatBaseController;
class OrderController extends WeChatBaseController
{
/**
* 全部订单
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function get_all(){
$state = $this->request->param('state',0,'intval');
// if(!empty($state)){
// $where1['state'] = ['eq',$state];
// }
$user_id = cmf_get_current_user_id();
$orderModel = new OrderModel();
$where['uid'] = ['eq',$user_id];
$data = $orderModel->selectData($where);
$indentModel = new IndentModel();
$where1['uid'] = ['eq',$user_id];
$data = $indentModel->selectData($where1);
if(!empty($data)){
$indentGoodsModel = new IndentGoodsModel();
foreach($data as $key => $vo){
$where2['indent_id'] = ['eq',$vo['id']];
$indentGoods = $indentGoodsModel->selectData($where2);
$data[$key]['indent_goods'] = $indentGoods;
}
}
$this->assign('data',$data);
$this->assign('state',$state);
return $this->fetch();
}
public function get_one(){
$id = $this->request->param('id',0,'intval');
if(empty($id)){
$this->error('缺少必要参数','','','');
}
$user_id = cmf_get_current_user_id();
$where1['uid'] = ['eq',$user_id];
$where1['id'] = ['eq',$id];
$indentModel = new IndentModel();
$data = $indentModel->findData($where1);
if(empty($data)){
$this->error('未查询到该订单','','','');
}
$where2['indent_id'] = ['eq',$data['id']];
$indentGoodsModel = new IndentGoodsModel();
$indentGoods = $indentGoodsModel->selectData($where2);
$data['indent_goods'] = $indentGoods;
$this->assign('data',$data);
return $this->fetch();
}
public function cancel_order(){
$id = $this->request->param('id',0,'intval');
if(empty($id)){
$this->error('缺少必要参数','','','');
}
$where1['id'] = ['eq',$id];
$indentModel = new IndentModel();
$data = $indentModel->findData($where1);
if(empty($data)){
$this->error('缺少必要参数','','','');
}
if($data['state'] != 4){
$this->error('订单不是待支付状态','','','');
}
$result = $indentModel->deleteData($where1);
if(empty($result)){
$this->error('sql执行失败','','','');
}
$this->redirect('order/get_all');
}
}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2019/6/5
* Time: 19:56
* Time: 20:27
*/
namespace app\portal\model;
... ... @@ -11,8 +11,16 @@ namespace app\portal\model;
use think\Model;
class OrderModel extends Model
class IndentGoodsModel extends Model
{
/**
* 获取多个订单明细
* @param $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectData($where){
$data = $this->where($where)->select()->toArray();
return $data;
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/6/5
* Time: 19:56
*/
namespace app\portal\model;
use think\Model;
class IndentModel extends Model
{
/**
* 获取多个订单
* @param $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectData($where){
$data = $this->where($where)->order('create_time desc')->select()->toArray();
return $data;
}
/**
* 获取单条数据
* @param $where
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function findData($where){
$data = $this->where($where)->find();
return $data;
}
/**
* 删除订单
* @param $where
* @return int
*/
public function deleteData($where){
$result = $this->where($where)->delete();
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -39,4 +39,4 @@ define('BRONET_VERSION', '5.0.170927');
require CMF_ROOT . 'simplewind/thinkphp/base.php';
// 执行应用
\think\App::run()->send();
\think\App::run()->send();
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>学考无忧-我的订单</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css" />
</head>
<body>
<div class="myorder_box">
<!-- 顶部 -->
<div class="order_top">
<img src="__TMPL__/public/assets/images/left.png" alt="" />
<p>我的订单</p>
</div>
<!-- 头部 -->
<div class="myor_title">
<ul>
<li class="<if condition='$state eq 0'>myor_title_active</if>">全部</li>
<li class="<if condition='$state eq 4'>myor_title_active</if>">待付款</li>
<li class="<if condition='$state eq 2'>myor_title_active</if>">待发货</li>
<li class="<if condition='$state eq 5'>myor_title_active</if>">已发货</li>
<li class="<if condition='$state eq 3'>myor_title_active</if>">已完成</li>
</ul>
</div>
<!-- 内容 -->
<div class="myorder_content">
<!-- 全部 -->
<div class="myorder_con1" style="display: block">
<foreach name="data" item="vo">
<a href="">
<div class="myorder_information">
<!-- 订单 -->
<div class="myorder_the">
<p class="order_dan">订单号:{$vo.order_number}</p>
<div class="myorder_state1">
<if condition="$vo.state eq 4">
待付款
<elseif condition="$vo.state eq 2"/>
待发货
<elseif condition="$vo.state eq 5"/>
已发货
<elseif condition="$vo.state eq 3"/>
已完成
</if>
</div>
</div>
<ul class="order_newsUl myorder_border">
<foreach name="$vo.indent_goods" item="i_g">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($i_g.thumbnail)}" alt="" />
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">
{$i_g.book_name}
</div>
<div class="order_newsTxt2">×<span>{$i_g.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$i_g.price}</span></p>
<p class="de_topTxt1_2"><span>{$i_g.pricing}</span></p>
</div>
</div>
</li>
</foreach>
<div class="my_ordera">
<span>共{:count($vo.indent_goods)}件商品 合计:</span>
<p>¥{$vo.money}</p>
</div>
</ul>
<!-- 时间/底部 -->
<div class="myorder_bottom">
<div class="myorder_bottom1">
<div class="myorder_bottom1Img">
<img src="__TMPL__/public/assets/images/52.png" alt="" />
</div>
<p class="myorder_bottom1Txt">{:date('Y-m-d H:i:s',$vo['create_time'])}</p>
</div>
<div class="myorder_bottom2">
<if condition="$vo.state eq 4">
<div class="myorder_bottom2_1">取消订单</div>
<div class="myorder_bottom2_2">去支付</div>
<elseif condition="$vo.state eq 2"/>
<a href="w_Ypayment.html">
<div class="myorder_bottom2_2">查看订单</div>
</a>
<elseif condition="$vo.state eq 5"/>
<a href="w_logistics.html">
<div class="myorder_bottom2_2">查看物流</div>
</a>
<elseif condition="$vo.state eq 3"/>
<div class="myorder_bottom2_2">去评价</div>
</if>
</div>
</div>
</div>
</a>
</foreach>
</div>
<!-- 待付款 -->
<div class="myorder_con1">
<foreach name="data" item="vo">
<if condition="$vo.state eq 4">
<a href="">
<div class="myorder_information">
<!-- 订单 -->
<div class="myorder_the">
<p class="order_dan">订单号:{$vo.order_number}</p>
<div class="myorder_state1">
<if condition="$vo.state eq 4">
待付款
<elseif condition="$vo.state eq 2"/>
待发货
<elseif condition="$vo.state eq 5"/>
已发货
<elseif condition="$vo.state eq 3"/>
已完成
</if>
</div>
</div>
<ul class="order_newsUl myorder_border">
<foreach name="$vo.indent_goods" item="i_g">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($i_g.thumbnail)}" alt="" />
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">
{$i_g.book_name}
</div>
<div class="order_newsTxt2">×<span>{$i_g.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$i_g.price}</span></p>
<p class="de_topTxt1_2"><span>{$i_g.pricing}</span></p>
</div>
</div>
</li>
</foreach>
<div class="my_ordera">
<span>共{:count($vo.indent_goods)}件商品 合计:</span>
<p>¥{$vo.money}</p>
</div>
</ul>
<!-- 时间/底部 -->
<div class="myorder_bottom">
<div class="myorder_bottom1">
<div class="myorder_bottom1Img">
<img src="__TMPL__/public/assets/images/52.png" alt="" />
</div>
<p class="myorder_bottom1Txt">{:date('Y-m-d H:i:s',$vo['create_time'])}</p>
</div>
<div class="myorder_bottom2">
<if condition="$vo.state eq 4">
<div class="myorder_bottom2_1">取消订单</div>
<div class="myorder_bottom2_2">去支付</div>
<elseif condition="$vo.state eq 2"/>
<a href="w_Ypayment.html">
<div class="myorder_bottom2_2">查看订单</div>
</a>
<elseif condition="$vo.state eq 5"/>
<a href="w_logistics.html">
<div class="myorder_bottom2_2">查看物流</div>
</a>
<elseif condition="$vo.state eq 3"/>
<div class="myorder_bottom2_2">去评价</div>
</if>
</div>
</div>
</div>
</a>
</if>
</foreach>
</div>
<!-- 待发货 -->
<div class="myorder_con1">
<foreach name="data" item="vo">
<if condition="$vo.state eq 2">
<a href="">
<div class="myorder_information">
<!-- 订单 -->
<div class="myorder_the">
<p class="order_dan">订单号:{$vo.order_number}</p>
<div class="myorder_state1">
<if condition="$vo.state eq 4">
待付款
<elseif condition="$vo.state eq 2"/>
待发货
<elseif condition="$vo.state eq 5"/>
已发货
<elseif condition="$vo.state eq 3"/>
已完成
</if>
</div>
</div>
<ul class="order_newsUl myorder_border">
<foreach name="$vo.indent_goods" item="i_g">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($i_g.thumbnail)}" alt="" />
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">
{$i_g.book_name}
</div>
<div class="order_newsTxt2">×<span>{$i_g.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$i_g.price}</span></p>
<p class="de_topTxt1_2"><span>{$i_g.pricing}</span></p>
</div>
</div>
</li>
</foreach>
<div class="my_ordera">
<span>共{:count($vo.indent_goods)}件商品 合计:</span>
<p>¥{$vo.money}</p>
</div>
</ul>
<!-- 时间/底部 -->
<div class="myorder_bottom">
<div class="myorder_bottom1">
<div class="myorder_bottom1Img">
<img src="__TMPL__/public/assets/images/52.png" alt="" />
</div>
<p class="myorder_bottom1Txt">{:date('Y-m-d H:i:s',$vo['create_time'])}</p>
</div>
<div class="myorder_bottom2">
<if condition="$vo.state eq 4">
<div class="myorder_bottom2_1">取消订单</div>
<div class="myorder_bottom2_2">去支付</div>
<elseif condition="$vo.state eq 2"/>
<a href="w_Ypayment.html">
<div class="myorder_bottom2_2">查看订单</div>
</a>
<elseif condition="$vo.state eq 5"/>
<a href="w_logistics.html">
<div class="myorder_bottom2_2">查看物流</div>
</a>
<elseif condition="$vo.state eq 3"/>
<div class="myorder_bottom2_2">去评价</div>
</if>
</div>
</div>
</div>
</a>
</if>
</foreach>
</div>
<!-- 已发货 -->
<div class="myorder_con1">
<foreach name="data" item="vo">
<if condition="$vo.state eq 5">
<a href="">
<div class="myorder_information">
<!-- 订单 -->
<div class="myorder_the">
<p class="order_dan">订单号:{$vo.order_number}</p>
<div class="myorder_state1">
<if condition="$vo.state eq 4">
待付款
<elseif condition="$vo.state eq 2"/>
待发货
<elseif condition="$vo.state eq 5"/>
已发货
<elseif condition="$vo.state eq 3"/>
已完成
</if>
</div>
</div>
<ul class="order_newsUl myorder_border">
<foreach name="$vo.indent_goods" item="i_g">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($i_g.thumbnail)}" alt="" />
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">
{$i_g.book_name}
</div>
<div class="order_newsTxt2">×<span>{$i_g.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$i_g.price}</span></p>
<p class="de_topTxt1_2"><span>{$i_g.pricing}</span></p>
</div>
</div>
</li>
</foreach>
<div class="my_ordera">
<span>共{:count($vo.indent_goods)}件商品 合计:</span>
<p>¥{$vo.money}</p>
</div>
</ul>
<!-- 时间/底部 -->
<div class="myorder_bottom">
<div class="myorder_bottom1">
<div class="myorder_bottom1Img">
<img src="__TMPL__/public/assets/images/52.png" alt="" />
</div>
<p class="myorder_bottom1Txt">{:date('Y-m-d H:i:s',$vo['create_time'])}</p>
</div>
<div class="myorder_bottom2">
<if condition="$vo.state eq 4">
<div class="myorder_bottom2_1">取消订单</div>
<div class="myorder_bottom2_2">去支付</div>
<elseif condition="$vo.state eq 2"/>
<a href="w_Ypayment.html">
<div class="myorder_bottom2_2">查看订单</div>
</a>
<elseif condition="$vo.state eq 5"/>
<a href="w_logistics.html">
<div class="myorder_bottom2_2">查看物流</div>
</a>
<elseif condition="$vo.state eq 3"/>
<div class="myorder_bottom2_2">去评价</div>
</if>
</div>
</div>
</div>
</a>
</if>
</foreach>
</div>
<!-- 已完成 -->
<div class="myorder_con1">
<foreach name="data" item="vo">
<if condition="$vo.state eq 3">
<a href="">
<div class="myorder_information">
<!-- 订单 -->
<div class="myorder_the">
<p class="order_dan">订单号:{$vo.order_number}</p>
<div class="myorder_state1">
<if condition="$vo.state eq 4">
待付款
<elseif condition="$vo.state eq 2"/>
待发货
<elseif condition="$vo.state eq 5"/>
已发货
<elseif condition="$vo.state eq 3"/>
已完成
</if>
</div>
</div>
<ul class="order_newsUl myorder_border">
<foreach name="$vo.indent_goods" item="i_g">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($i_g.thumbnail)}" alt="" />
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">
{$i_g.book_name}
</div>
<div class="order_newsTxt2">×<span>{$i_g.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$i_g.price}</span></p>
<p class="de_topTxt1_2"><span>{$i_g.pricing}</span></p>
</div>
</div>
</li>
</foreach>
<div class="my_ordera">
<span>共{:count($vo.indent_goods)}件商品 合计:</span>
<p>¥{$vo.money}</p>
</div>
</ul>
<!-- 时间/底部 -->
<div class="myorder_bottom">
<div class="myorder_bottom1">
<div class="myorder_bottom1Img">
<img src="__TMPL__/public/assets/images/52.png" alt="" />
</div>
<p class="myorder_bottom1Txt">{:date('Y-m-d H:i:s',$vo['create_time'])}</p>
</div>
<div class="myorder_bottom2">
<if condition="$vo.state eq 4">
<div class="myorder_bottom2_1">取消订单</div>
<div class="myorder_bottom2_2">去支付</div>
<elseif condition="$vo.state eq 2"/>
<a href="w_Ypayment.html">
<div class="myorder_bottom2_2">查看订单</div>
</a>
<elseif condition="$vo.state eq 5"/>
<a href="w_logistics.html">
<div class="myorder_bottom2_2">查看物流</div>
</a>
<elseif condition="$vo.state eq 3"/>
<div class="myorder_bottom2_2">去评价</div>
</if>
</div>
</div>
</div>
</a>
</if>
</foreach>
</div>
</div>
</div>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script>
function load(){
var index = $(".myor_title ul li").index($('.myor_title_active'));
$(".myorder_con1").eq(index).show().siblings().hide();
}
$(function() {
load();
// myor_title_active
$(".myor_title ul li").click(function() {
console.log($(this));
$(this)
.addClass("myor_title_active")
.siblings()
.removeClass("myor_title_active");
var index = $(this).index();
$(".myorder_con1")
.eq(index)
.show()
.siblings()
.hide();
});
})
</script>
</body>
</html>
\ No newline at end of file
... ...