作者 jinglong
1 个管道 的构建 通过 耗费 6 秒

修改销量增加接口

... ... @@ -37,6 +37,8 @@ class Bcoupon extends Backend
$arr[$value['id']] = $value['name'].'------'.$value['address'];
}
$this->assign('btype',$arr);
$this->assign('gift',['无','分享人','被分享人']);
}
/**
... ...
... ... @@ -29,6 +29,7 @@ class Coupon extends Backend
$this->assign('r_type',['满减券','折扣券']);
$this->assign('coupon_type',['减少券','折扣券']);
$this->assign('is_new',['否','是']);
$this->assign('gift',['无','分享人','被分享人']);
}
/**
... ... @@ -71,7 +72,7 @@ class Coupon extends Backend
->select();
foreach ($list as $row) {
$row->visible(['id','c_type','is_new','type','reduce','discount','coupon_number','createtime','coupon_type','end_time','coupon_name']);
$row->visible(['id','c_type','is_new','gift','type','reduce','discount','coupon_number','createtime','coupon_type','end_time','coupon_name']);
}
$list = collection($list)->toArray();
... ...
... ... @@ -37,6 +37,8 @@ class Gcoupon extends Backend
$arr[$value['id']] = $value['name'];
}
$this->assign('goods',$arr);
$this->assign('gift',['无','分享人','被分享人']);
}
/**
... ...
... ... @@ -5,6 +5,7 @@ return [
'Bg_name' => '品牌名称',
'Bg_address' => '品牌产地',
'Is_new' => '新人专享',
'Gift' => '分享礼包',
'Bg_id' => '品牌分类',
'Coupon_name' => '优惠券名称',
'C_type' => '优惠券类型',
... ...
... ... @@ -5,6 +5,7 @@ return [
'C_type' => '优惠券类型',
'Coupon_type' => '优惠类型',
'Is_new' => '新人专享',
'Gift' => '分享礼包',
'Full_reduce' => '满减金额',
'Coupon_name' => '优惠券名称',
'Reduce' => '减少金额',
... ...
... ... @@ -5,6 +5,7 @@ return [
'Goods' => '商品名称',
'Bg_id' => '品牌分类',
'Is_new' => '新人专享',
'Gift' => '分享礼包',
'C_type' => '优惠券类型',
'Coupon_name' => '优惠券名称',
'Coupon_type' => '优惠类型',
... ...
... ... @@ -16,6 +16,9 @@ return [
'Tag' => '商品标签',
'Stock' => '商品库存',
'Sort' => '排序',
'Hots' => '热度',
'Sales' => '销售量',
'Collections' => '收藏量',
'Introduce' => '商品简介',
'Detail' => '商品详情',
'Createtime' => '创建时间',
... ...
... ... @@ -16,6 +16,9 @@ return [
'Tag' => '商品标签',
'Stock' => '商品库存',
'Sort' => '排序',
'Hots' => '热度',
'Sales' => '销售量',
'Collections' => '收藏量',
'Introduce' => '商品简介',
'Detail' => '商品详情',
'Createtime' => '创建时间',
... ...
... ... @@ -68,6 +68,12 @@
<input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gift')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[gift]', $gift, null, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -60,6 +60,12 @@
<input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="{$row.end_time|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gift')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[gift]', $gift, $row.gift, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -62,6 +62,12 @@
<input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gift')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[gift]', $gift, null, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -54,6 +54,12 @@
<input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="{$row.end_time|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gift')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[gift]', $gift, $row.gift, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -68,6 +68,12 @@
<input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gift')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[gift]', $gift, null, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -60,6 +60,12 @@
<input id="c-end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="{$row.end_time|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gift')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[gift]', $gift, $row.gift, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -53,12 +53,6 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('New_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-new_price" class="form-control" step="0.01" name="row[new_price]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sale_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sale_price" class="form-control" step="0.01" name="row[sale_price]" type="number" value="0.00">
... ...
... ... @@ -53,12 +53,6 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('New_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-new_price" class="form-control" step="0.01" name="row[new_price]" type="number" value="{$row.new_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sale_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sale_price" class="form-control" step="0.01" name="row[sale_price]" type="number" value="{$row.sale_price|htmlentities}">
... ...
... ... @@ -53,12 +53,6 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('New_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-new_price" class="form-control" step="0.01" name="row[new_price]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sale_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sale_price" class="form-control" step="0.01" name="row[sale_price]" type="number" value="0.00">
... ...
... ... @@ -53,12 +53,6 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('New_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-new_price" class="form-control" step="0.01" name="row[new_price]" type="number" value="{$row.new_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sale_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sale_price" class="form-control" step="0.01" name="row[sale_price]" type="number" value="{$row.sale_price|htmlentities}">
... ...
... ... @@ -486,4 +486,19 @@ class Common
$rCouponModel = new Rcoupon();
$rCouponModel->where(['uid'=>$uid,'c_id'=>$coupon_id])->update(['is_use'=>$is_use]);
}
/**
* 购买成功,更新订单号,销量增加1
* @ApiInternal
*/
public static function incSales($out_trade_no){
$status = config('verify.status');
//更新订单号成功
$orderModel = new Order();
$orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2]]);
$goodsModel = new \app\admin\model\Goods();
//销量增加1
$res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id');
$goodsModel->where(['id'=>$res['id']])->setInc('sales',1);
}
}
... ...
... ... @@ -112,10 +112,8 @@ class Pay extends Api
if ($message['return_code'] === 'SUCCESS') {
if ($message['result_code'] === 'SUCCESS') {
//支付成功,更新订单状态
$status = $this->order_status;
$orderModel = new Order();
$orderModel->where(['pay_order_sn'=>$message['out_trade_no'],'status'=>$status[0]])->update(['status'=>$status[2]]);
//支付成功,更新订单号,销量增加1
Common::incSales($message['out_trade_no']);
}elseif($message['result_code'] === 'FAIL') {
//支付失败
}
... ... @@ -220,10 +218,8 @@ class Pay extends Api
//return_code 表示通信状态
if ($message['return_code'] === 'SUCCESS') {
if ($message['result_code'] === 'SUCCESS') {
//支付成功
$status = $this->order_status;
$orderModel = new Order();
$orderModel->where(['pay_order_sn'=>$message['out_trade_no'],'status'=>$status[0]])->update(['status'=>$status[2]]);
//支付成功,更新订单号,销量增加1
Common::incSales($message['out_trade_no']);
}elseif($message['result_code'] === 'FAIL') {
//支付失败,好像有问题
}
... ...
... ... @@ -3,6 +3,7 @@
namespace app\api\controller;
use app\admin\model\Collection;
use app\admin\model\Rcoupon;
use app\common\controller\Api;
use fast\Http;
use think\Validate;
... ... @@ -215,6 +216,8 @@ class User extends Api
}else{
$res = $collectionModel->create(['g_id'=>$goods_id,'uid'=>$this->uid]);
if($res){
$goodsModel = new \app\admin\model\Goods();
$goodsModel->where(['id'=>$goods_id])->setInc('collections',1);
$this->success('成功');
}else{
$this->error('失败');
... ... @@ -252,6 +255,8 @@ class User extends Api
$collectionModel = new Collection();
$res = $collectionModel->where(['uid'=>$this->uid,'g_id'=>$goods_id])->delete();
if($res){
$goodsModel = new \app\admin\model\Goods();
$goodsModel->where(['id'=>$goods_id])->setDec('collections',1);
$this->success('成功');
}else{
$this->error('失败');
... ... @@ -449,4 +454,65 @@ class User extends Api
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (分享获取礼包)
* @ApiSummary (分享获取礼包)
* @ApiMethod (POST)
* @ApiRoute (/api/user/share)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="share_uid", type="inter", required=true, description="分享人uid")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571037179",
"data": null
})
*/
public function share(){
if($this->request->isPost()){
$share_uid = $this->request->post('share_uid');
$rule = config('verify.share');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['share_uid'=>$share_uid])) {
$this->error($validate->getError());
}
$rCouponModel = new Rcoupon();
//查询分享人已领取优惠券
$receive = Common::selectWhereData('rcoupon',['uid'=>$share_uid],'id,c_id');
$receive_s = array_column($receive,'c_id');
//查询分享人优惠券
$res_coupon = Common::selectWhereData('coupon',['gift'=>1,'end_time'=>['>',time()]],'id');
$res_coupon = array_column($res_coupon,'id');
$res = array_diff($res_coupon,$receive_s);//数组1不存在数组2中的数组
$arr = [];
foreach($res as $key=>$value){
$arr[$key]['uid'] = $share_uid;
$arr[$key]['c_id'] = $value;
$arr[$key]['is_share'] = 1;
}
$rCouponModel->saveAll($arr);
//查询被分享人已领取优惠券
$receive = Common::selectWhereData('rcoupon',['uid'=>$this->uid],'id,c_id');
$receive_s = array_column($receive,'c_id');
//查询分享人优惠券
$res_coupon = Common::selectWhereData('coupon',['gift'=>2,'end_time'=>['>',time()]],'id');
$res_coupon = array_column($res_coupon,'id');
$res = array_diff($res_coupon,$receive_s);//数组1不存在数组2中的数组
$arr1 = [];
foreach($res as $key=>$value){
$arr1[$key]['uid'] = $this->uid;
$arr1[$key]['c_id'] = $value;
$arr1[$key]['is_share'] = 1;
}
$rCouponModel->saveAll($arr1);
$this->success('成功');
}else{
$this->error('请求方式错误');
}
}
}
... ...
... ... @@ -7,8 +7,8 @@ return [
],
//快递鸟配置
'express'=>[
'EBusinessID' =>'1442433',
'appKey' =>'59387773-4d1c-4006-a5c6-159261ed4fef',
'EBusinessID' =>'1576495',
'appKey' =>'a504b6fa-f6a1-4de0-82f1-fd6d7b4927a5',
'url' =>'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',//请求地址
],
//微信支付配置
... ... @@ -306,4 +306,14 @@ return [
'return_reason.require' => '退货/换货原因不能为空',
]
],
//分享
'share' => [
'rule' => [
'share_uid' => 'require|number',
],
'msg' => [
'share_uid.require' => '分享人id不能为空',
'share_uid.number' => '分享人id必须为数字',
]
],
];
\ No newline at end of file
... ...
... ... @@ -222,6 +222,7 @@
<a href="javascript:;" data-id="42" class="list-group-item">取消收藏</a>
<a href="javascript:;" data-id="43" class="list-group-item">我的收藏</a>
<a href="javascript:;" data-id="44" class="list-group-item">我的优惠券</a>
<a href="javascript:;" data-id="45" class="list-group-item">分享获取礼包</a>
</div>
</div>
</div>
... ... @@ -7121,13 +7122,156 @@
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-45">
<h4 class="panel-title">
<span class="label label-primary">POST</span>
<a data-toggle="collapse" data-parent="#accordion45" href="#collapseOne45"> 分享获取礼包 <span class="text-muted">/api/user/share</span></a>
</h4>
</div>
<div id="collapseOne45" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab45">
<li class="active"><a href="#info45" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox45" data-toggle="tab">在线测试</a></li>
<li><a href="#sample45" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info45">
<div class="well">
分享获取礼包 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>token</td>
<td>string</td>
<td></td>
<td>请求的Token</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>share_uid</td>
<td>inter</td>
<td></td>
<td>分享人uid</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>正文</strong></div>
<div class="panel-body">
</div>
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox45">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<div class="headers">
<div class="form-group">
<label class="control-label" for="token">token</label>
<input type="string" class="form-control input-sm" id="token" required placeholder="请求的Token - Ex: " name="token">
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/user/share" method="POST" name="form45" id="form45">
<div class="form-group">
<label class="control-label" for="share_uid">share_uid</label>
<input type="inter" class="form-control input-sm" id="share_uid" required placeholder="分享人uid" name="share_uid">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="45">提交</button>
<button type="reset" class="btn btn-info" rel="45">重置</button>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>响应输出</strong></div>
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers45"></pre>
<pre id="response45"></pre>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>返回参数</strong></div>
<div class="panel-body">
</div>
</div>
</div>
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample45">
<div class="row">
<div class="col-md-12">
<pre id="sample_response45">{
"code": 1,
"msg": "成功",
"time": "1571037179",
"data": null
}</pre>
</div>
</div>
</div><!-- #sample -->
</div><!-- .tab-content -->
</div>
</div>
</div>
</div>
<hr>
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2019-12-05 17:14:02 </div>
Generated on 2019-12-05 19:38:12 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...
... ... @@ -74,6 +74,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'coupon_number', title: __('coupon_number')},
{field: 'is_new', title: __('Is_new'),formatter: Table.api.formatter.label,searchList: {0: __('否'), 1: __('是')}},
{field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'gift', title: __('Gift'),formatter: Table.api.formatter.label,searchList: {0: __('无'), 1: __('分享人'),2:__('被分享人')}},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...
... ... @@ -72,6 +72,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'coupon_number', title: __('Coupon_number')},
{field: 'is_new', title: __('Is_new'),formatter: Table.api.formatter.label,searchList: {0: __('否'), 1: __('是')}},
{field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'gift', title: __('Gift'),formatter: Table.api.formatter.label,searchList: {0: __('无'), 1: __('分享人'),2:__('被分享人')}},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...
... ... @@ -73,6 +73,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'coupon_number', title: __('coupon_number')},
{field: 'is_new', title: __('Is_new'),formatter: Table.api.formatter.label,searchList: {0: __('否'), 1: __('是')}},
{field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'gift', title: __('Gift'),formatter: Table.api.formatter.label,searchList: {0: __('无'), 1: __('分享人'),2:__('被分享人')}},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...
... ... @@ -53,6 +53,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'market_price', title: __('Market_price'), operate:'BETWEEN'},//市场价格
{field: 'expense_price', title: __('Expense_price'), operate:'BETWEEN'},//运费
{field: 'sort', title: __('Sort')},//排序
{field: 'sort', title: __('Sort')},//排序
{field: 'hots', title: __('Hots')},//浏览量
{field: 'sales', title: __('Sales')},//销量
{field: 'collections', title: __('Collections')},//收藏量
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...
... ... @@ -54,6 +54,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'market_price', title: __('Market_price'), operate:'BETWEEN'},//市场价格
{field: 'expense_price', title: __('Expense_price'), operate:'BETWEEN'},//运费
{field: 'sort', title: __('Sort')},//排序
{field: 'hots', title: __('Hots')},//浏览量
{field: 'sales', title: __('Sales')},//销量
{field: 'collections', title: __('Collections')},//收藏量
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...