初始上传
This commit is contained in:
167
addon/presale/api/controller/Goods.php
Executable file
167
addon/presale/api/controller/Goods.php
Executable file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\api\controller;
|
||||
|
||||
use addon\presale\model\Presale as PresaleModel;
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
use addon\presale\model\PresaleOrderRefund;
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\presale\model\Poster;
|
||||
use app\model\goods\GoodsApi;
|
||||
|
||||
/**
|
||||
* 预售商品
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 预售商品详情信息
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$presale_id = $this->params['id'] ?? 0;
|
||||
if (empty($presale_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_PRESALE_ID'));
|
||||
}
|
||||
$sku_id = $this->params['sku_id'] ?? 0;
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
$condition = [
|
||||
[ 'pp.presale_id', '=', $presale_id ],
|
||||
[ 'pp.site_id', '=', $this->site_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
if ($sku_id > 0) {
|
||||
$condition[] = [ 'ppg.sku_id', '=', $sku_id ];
|
||||
}
|
||||
$goods_sku_detail = $presale_model->getPresaleGoodsDetail($condition)[ 'data' ];
|
||||
if (empty($goods_sku_detail)) {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
|
||||
$res = [];
|
||||
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
|
||||
$res[ 'goods_sku_detail' ][ 'purchased_num' ] = 0;
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] >= 0) {
|
||||
$res[ 'goods_sku_detail' ][ 'purchased_num' ] = $presale_model->getGoodsPurchasedNum($goods_sku_detail[ 'presale_id' ], $this->member_id);
|
||||
$res[ 'goods_sku_detail' ][ 'buying_num' ] = $presale_model->getPresaleOrderCount([
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
[ 'presale_id', '=', $goods_sku_detail[ 'presale_id' ] ],
|
||||
[ 'order_status', 'not in', [ PresaleOrderCommon::ORDER_CLOSE, PresaleOrderCommon::ORDER_PAY ] ],
|
||||
[ 'refund_status', '<>', PresaleOrderRefund::REFUND_COMPLETE ]
|
||||
])[ 'data' ];
|
||||
}
|
||||
// 预约人数
|
||||
$res[ 'goods_sku_detail' ][ 'sale_num' ] = $presale_model->getPresaleOrderCount([
|
||||
[ 'presale_id', '=', $goods_sku_detail[ 'presale_id' ] ],
|
||||
[ 'order_status', '<>', PresaleOrderCommon::ORDER_CLOSE ]
|
||||
])[ 'data' ];
|
||||
|
||||
// 处理公共数据
|
||||
$goods_sku_api = new GoodsApi();
|
||||
$goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ], $this->member_id, $this->site_id);
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品SKU集合
|
||||
* @return false|string
|
||||
*/
|
||||
public function goodsSku()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$presale_id = $this->params['presale_id'] ?? 0;
|
||||
if (empty($presale_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_PRESALE_ID'));
|
||||
}
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
|
||||
$condition = [
|
||||
[ 'pp.presale_id', '=', $presale_id ],
|
||||
[ 'g.goods_id', '=', $goods_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'pp.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
];
|
||||
$list = $presale_model->getPresaleGoodsSkuList($condition);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function page()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$goods_id_arr = $this->params['goods_id_arr'] ?? '';//goods_id数组
|
||||
|
||||
$condition = [
|
||||
[ 'pp.status', '=', 1 ],// 状态(0未开始 1进行中 2已结束)
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.site_id', '=', $this->site_id ]
|
||||
];
|
||||
|
||||
if (!empty($goods_id_arr)) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
|
||||
}
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
$list = $presale_model->getPresaleGoodsPageList($condition, $page, $page_size, 'pp.presale_id desc', '');
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$num = $this->params['num'] ?? 0;
|
||||
|
||||
$condition = [
|
||||
[ 'pp.status', '=', 1 ],// 状态(0未开始 1进行中 2已结束)
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.site_id', '=', $this->site_id ]
|
||||
];
|
||||
|
||||
if (!empty($goods_id_arr)) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
|
||||
}
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
$list = $presale_model->getPresaleList($condition, '', 'pp.presale_id desc', $num);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品海报
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
$promotion_type = 'presale';
|
||||
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
|
||||
$qrcode_param[ 'source_member' ] = $this->member_id;
|
||||
$poster = new Poster();
|
||||
$res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
148
addon/presale/api/controller/Order.php
Executable file
148
addon/presale/api/controller/Order.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\api\controller;
|
||||
|
||||
use addon\presale\model\PresaleOrder;
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
/**
|
||||
* 预售订单
|
||||
*/
|
||||
class Order extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$condition = [
|
||||
[ 'ppo.site_id', '=', $this->site_id ],
|
||||
[ 'ppo.member_id', '=', $this->member_id ]
|
||||
];
|
||||
|
||||
$order_status = $this->params['order_status'] ?? '';
|
||||
if ($order_status !== '') {
|
||||
$condition[] = [ 'ppo.order_status', '=', $order_status ];
|
||||
}
|
||||
|
||||
$presale_order_model = new PresaleOrder();
|
||||
$list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size);
|
||||
if (!empty($list[ 'data' ][ 'list' ])) {
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$action = empty($v[ "order_status_action" ]) ? [] : json_decode($v[ "order_status_action" ], true);
|
||||
$member_action = $action[ "member_action" ] ?? [];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'action' ] = $member_action;
|
||||
unset($list[ 'data' ][ 'list' ][ $k ][ 'order_status_action' ]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['order_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', '缺少必须参数order_id'));
|
||||
}
|
||||
|
||||
$presale_order_model = new PresaleOrder();
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
];
|
||||
$order_info = $presale_order_model->getPresaleOrderInfo($condition);
|
||||
if (!empty($order_info[ 'data' ])) {
|
||||
$action = empty($order_info[ 'data' ][ "order_status_action" ]) ? [] : json_decode($order_info[ 'data' ][ "order_status_action" ], true);
|
||||
$member_action = $action[ "member_action" ] ?? [];
|
||||
$order_info[ 'data' ][ 'action' ] = $member_action;
|
||||
unset($order_info[ 'data' ][ 'order_status_action' ]);
|
||||
}
|
||||
return $this->response($order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['order_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', '缺少必须参数order_id'));
|
||||
}
|
||||
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
];
|
||||
|
||||
$res = $order_common_model->depositOrderClose($condition);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['order_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', '缺少必须参数order_id'));
|
||||
}
|
||||
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
];
|
||||
|
||||
$res = $order_common_model->deleteOrder($condition);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定金或尾款交易流水号
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['id'] ?? ''; //预售订单id
|
||||
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
$res = $order_common_model->getPresaleOrderOutTradeNo($id, $this->member_id, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
130
addon/presale/api/controller/Ordercreate.php
Executable file
130
addon/presale/api/controller/Ordercreate.php
Executable file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* Index.php
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: http://www.niushop.com.cn
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
* @author : niuteam
|
||||
* @date : 2022.8.8
|
||||
* @version : v5.0.0.1
|
||||
*/
|
||||
|
||||
namespace addon\presale\api\controller;
|
||||
|
||||
use addon\presale\model\PresaleOrderCreate as OrderCreateModel;
|
||||
use app\api\controller\BaseOrderCreateApi;
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Ordercreate extends BaseOrderCreateApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 定金创建订单
|
||||
*/
|
||||
public function depositCreate()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params['order_key'] ?? '',
|
||||
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getInputParam(), $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->create();
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定金计算信息
|
||||
*/
|
||||
public function depositCalculate()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params[ 'order_key' ] ?? '', //订单缓存key
|
||||
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
||||
];
|
||||
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->confirm();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 待支付订单(定金)
|
||||
* @return string
|
||||
*/
|
||||
public function depositPayment()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'presale_id' => $this->params[ 'presale_id' ] ?? '', //预售id
|
||||
'sku_id' => $this->params[ 'sku_id' ] ?? '',
|
||||
'num' => $this->params[ 'num' ] ?? '',
|
||||
];
|
||||
if (empty($data[ 'presale_id' ]) && empty($data[ 'sku_id' ])) {
|
||||
return $this->response($this->error('', '缺少必填参数商品数据'));
|
||||
}
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->depositOrderPayment();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 待支付订单(尾款)
|
||||
* @return string
|
||||
*/
|
||||
// public function finalPayment()
|
||||
// {
|
||||
// $token = $this->checkToken();
|
||||
// if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
// $order_create = new OrderCreateModel();
|
||||
// $data = [
|
||||
// 'id' => $this->params[ 'id' ] ?? '', //预售订单id
|
||||
// 'site_id' => $this->site_id,//站点id
|
||||
// 'member_id' => $this->member_id,
|
||||
// 'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
||||
// 'pay_password' => isset($this->params[ 'pay_password' ]) ? $this->params[ 'pay_password' ] : '',//支付密码
|
||||
// ];
|
||||
// if (empty($data[ 'id' ])) {
|
||||
// return $this->response($this->error('', '缺少必填参数订单数据'));
|
||||
// }
|
||||
// $res = $order_create->finalCalculate($data);
|
||||
// return $this->response($this->success($res));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 尾款订单
|
||||
*/
|
||||
public function finalCreate()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'id' => $this->params[ 'id' ] ?? '', //预售订单id
|
||||
'site_id' => $this->site_id,//站点id
|
||||
'member_id' => $this->member_id,
|
||||
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
||||
'pay_password' => $this->params[ 'pay_password' ] ?? '',//支付密码
|
||||
];
|
||||
if (empty($data[ 'id' ])) {
|
||||
return $this->response($this->error('', '缺少必填参数订单数据'));
|
||||
}
|
||||
$res = $order_create->setParam($data)->payfinalMoneyPresaleOrder($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
125
addon/presale/api/controller/Refund.php
Executable file
125
addon/presale/api/controller/Refund.php
Executable file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\api\controller;
|
||||
|
||||
use addon\presale\model\PresaleOrder;
|
||||
use addon\presale\model\PresaleOrderRefund;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
/**
|
||||
* 预售订单退款
|
||||
*/
|
||||
class Refund extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
];
|
||||
|
||||
$refund_status = $this->params['refund_status'] ?? 0;
|
||||
if ($refund_status) {
|
||||
$condition[] = [ 'refund_status', '=', $refund_status ];
|
||||
} else {
|
||||
$condition[] = [ 'refund_status', '<>', 0 ];
|
||||
}
|
||||
|
||||
$presale_order_model = new PresaleOrder();
|
||||
$list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['order_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', '缺少必须参数order_id'));
|
||||
}
|
||||
|
||||
$presale_order_model = new PresaleOrder();
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
];
|
||||
$order_info = $presale_order_model->getPresaleOrderInfo($condition);
|
||||
return $this->response($order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款(定金)
|
||||
* @return false|string
|
||||
*/
|
||||
public function applyRefund()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['order_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', '缺少必须参数order_id'));
|
||||
}
|
||||
|
||||
$data = [
|
||||
'id' => $id,
|
||||
'site_id' => $this->site_id,
|
||||
'member_id' => $this->member_id
|
||||
];
|
||||
|
||||
$presale_order_refund_model = new PresaleOrderRefund();
|
||||
$res = $presale_order_refund_model->applyRefund($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消申请退款
|
||||
*/
|
||||
public function cancelRefund()
|
||||
{
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['order_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', '缺少必须参数order_id'));
|
||||
}
|
||||
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'member_id', '=', $this->member_id ]
|
||||
];
|
||||
|
||||
$presale_order_refund_model = new PresaleOrderRefund();
|
||||
$res = $presale_order_refund_model->cancelRefund($condition);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
21
addon/presale/component/controller/Presale.php
Executable file
21
addon/presale/component/controller/Presale.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace addon\presale\component\controller;
|
||||
|
||||
use app\component\controller\BaseDiyView;
|
||||
|
||||
/**
|
||||
* 预售模块·组件
|
||||
*
|
||||
*/
|
||||
class Presale extends BaseDiyView
|
||||
{
|
||||
|
||||
/**
|
||||
* 设计界面
|
||||
*/
|
||||
public function design()
|
||||
{
|
||||
return $this->fetch("presale/design.html");
|
||||
}
|
||||
}
|
||||
23
addon/presale/component/view/presale/css/design.css
Executable file
23
addon/presale/component/view/presale/css/design.css
Executable file
@@ -0,0 +1,23 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
/* 样式:单列 */
|
||||
.component-presale .presale-list .row1-of1{}
|
||||
.component-presale .presale-list .row1-of1 .item{display: flex;margin-bottom: 10px;padding: 8px;}
|
||||
.component-presale .presale-list .row1-of1 .item:last-child{margin-bottom: 0;}
|
||||
.component-presale .presale-list .row1-of1 .item .img-wrap {width: 100px;height: 100px;}
|
||||
.component-presale .presale-list .row1-of1 .item .img-wrap > img{width: 100%;}
|
||||
.component-presale .presale-list .row1-of1 .item .content{flex:1;margin-left: 10px;padding:3px 0;position: relative;}
|
||||
.component-presale .presale-list .row1-of1 .item .content .discount-price{font-weight: bold;font-size: 0;position: absolute;bottom: 5px;left: 0;}
|
||||
.component-presale .presale-list .row1-of1 .item .content .discount-price .unit{font-size: 12px;}
|
||||
.component-presale .presale-list .row1-of1 .item .content .discount-price .price{font-size: 16px;}
|
||||
.component-presale .presale-list .row1-of1 .item .content button{position: absolute;bottom: 5px;right: 10px;padding: 0 8px;font-size: 12px;height: 26px;line-height: 26px;}
|
||||
|
||||
/* 样式:横向滑动 */
|
||||
.component-presale .presale-list .horizontal-slide{display: flex;margin: 10px;overflow: hidden;}
|
||||
.component-presale .presale-list .horizontal-slide .item {width: 97px;box-sizing: border-box;}
|
||||
.component-presale .presale-list .horizontal-slide .item .img-wrap {width: 97px;height: 97px;overflow: hidden;position: relative;}
|
||||
.component-presale .presale-list .horizontal-slide .item .img-wrap > img{width: calc(100% + 1px);}
|
||||
.component-presale .presale-list .horizontal-slide .item .content {padding: 5px 10px;}
|
||||
.component-presale .presale-list .horizontal-slide .item .content .discount-price{margin-top: 5px;font-weight: bold;font-size: 0;}
|
||||
.component-presale .presale-list .horizontal-slide .item .content .discount-price .unit{font-size: 12px; height: 16px;}
|
||||
.component-presale .presale-list .horizontal-slide .item .content .discount-price .price{font-size: 16px;}
|
||||
259
addon/presale/component/view/presale/design.html
Executable file
259
addon/presale/component/view/presale/design.html
Executable file
@@ -0,0 +1,259 @@
|
||||
<nc-component :data="data[index]" class="component-presale">
|
||||
|
||||
<!-- 预览 -->
|
||||
<template slot="preview">
|
||||
<div class="presale-list" :style="{ backgroundColor: nc.componentBgColor,
|
||||
borderTopLeftRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0) }">
|
||||
<div :class="[nc.template,nc.style]">
|
||||
<template v-if="nc.tempData.previewList && Object.keys(nc.tempData.previewList).length">
|
||||
<div class="item" v-for="(item, previewIndex) in nc.tempData.previewList" :key="previewIndex"
|
||||
:style="{
|
||||
borderTopLeftRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
backgroundColor: nc.elementBgColor,
|
||||
marginLeft: nc.template == 'horizontal-slide' && (nc.slideMode == 'scroll' && nc.goodsMarginType=='diy' && (nc.goodsMarginNum+'px') || ((60 - nc.margin.both*2) /6 + 'px')) || '',
|
||||
marginRight: nc.template == 'horizontal-slide' && (nc.slideMode == 'scroll' && nc.goodsMarginType=='diy' && (nc.goodsMarginNum+'px') || ((60 - nc.margin.both*2) /6 + 'px')) || '',
|
||||
boxShadow: nc.ornament.type == 'shadow' ? ('0 0 5px ' + nc.ornament.color) : '',
|
||||
border: nc.ornament.type == 'stroke' ? '1px solid ' + nc.ornament.color : ''}">
|
||||
<div class="img-wrap" :style="{ borderRadius: nc.imgAroundRadius + 'px' }">
|
||||
<img :style="{ borderRadius: nc.imgAroundRadius + 'px' }" :src="changeImgUrl('public/static/img/default_img/square.png')" />
|
||||
</div>
|
||||
<div class="content" v-if="nc.goodsNameStyle.control || nc.priceStyle.mainControl || nc.btnStyle.control">
|
||||
<div class="goods-name" v-if="nc.goodsNameStyle.control" :style="{ color : nc.goodsNameStyle.color,fontWeight : nc.goodsNameStyle.fontWeight ? 'bold' : '' }" :class="[{'using-hidden' : nc.nameLineMode == 'single'},{'multi-hidden' : nc.nameLineMode == 'multiple'}]">{{ item.goods_name }}</div>
|
||||
<div class="discount-price" v-if="nc.priceStyle.mainControl">
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">¥</span>
|
||||
<span class="price" :style="{ color : nc.priceStyle.mainColor }">{{item.discount_price.split(".")[0]}}</span>
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">{{"."+item.discount_price.split(".")[1]}}</span>
|
||||
</div>
|
||||
<button v-if="nc.btnStyle.control" class="layui-btn" :style="{ background : 'linear-gradient(to right,' + nc.btnStyle.bgColorStart + ',' + nc.btnStyle.bgColorEnd + ')', color : nc.btnStyle.textColor,borderRadius : nc.btnStyle.aroundRadius + 'px' }">{{ nc.btnStyle.text }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 内容编辑 -->
|
||||
<template slot="edit-content">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<presale-list-sources></presale-list-sources>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品样式</h3>
|
||||
<div class="layui-form-item list-style" v-if="nc.tempData.templateList">
|
||||
<label class="layui-form-label sm">风格</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source">{{ nc.tempData.templateList[nc.template].text }}</div>
|
||||
<div class="template-selected">
|
||||
<div v-for="(item,templateKey) in nc.tempData.templateList" :key="templateKey" class="source-item" :title="item.text"
|
||||
@click="nc.tempData.methods.selectTemplate(templateKey)"
|
||||
:class="[(nc.template == templateKey) ? 'text-color border-color' : '' ]">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 暂时只有一种样式,先隐藏 -->
|
||||
<!-- <div class="style-selected">-->
|
||||
<!-- <div v-for="(item,styleIndex) in nc.tempData.templateList[nc.template].styleList" :key="styleIndex" @click="nc.tempData.methods.selectTemplate('',item)" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.style==item.value) }">-->
|
||||
<!-- <i class="layui-anim layui-icon">{{ nc.style == item.value ? "" : "" }}</i>-->
|
||||
<!-- <div>{{item.text}}</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品数据</h3>
|
||||
<div class="layui-form-item" v-if="nc.tempData.goodsSources">
|
||||
<label class="layui-form-label sm">数据来源</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source-selected">
|
||||
<div class="source">{{ nc.tempData.goodsSources[nc.sources].text }}</div>
|
||||
<div v-for="(item,sourcesKey) in nc.tempData.goodsSources" :key="sourcesKey" class="source-item" :title="item.text" @click="nc.sources=sourcesKey" :class="{ 'text-color border-color' : (nc.sources == sourcesKey) }">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.sources == 'diy'">
|
||||
<label class="layui-form-label sm">手动选择</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="selected-style" @click="nc.tempData.methods.addGoods()">
|
||||
<span v-if="nc.goodsId.length == 0">请选择</span>
|
||||
<span v-if="nc.goodsId.length > 0" class="text-color">已选{{ nc.goodsId.length }}个</span>
|
||||
<i class="iconfont iconyoujiantou"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<slide :data="{ field : 'count', label: '商品数量', min:1, max: 30}" v-if="nc.sources != 'diy'"></slide>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">是否显示</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.btnStyle.control = !nc.btnStyle.control" :class="{ 'layui-form-checked' : nc.btnStyle.control }">
|
||||
<span>{{ nc.btnStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.btnStyle.control">
|
||||
<label class="layui-form-label sm">文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.btnStyle.text" maxlength="6" placeholder="请输入按钮文字" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>显示内容</h3>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.control = !nc.goodsNameStyle.control" :class="{ 'layui-form-checked' : nc.goodsNameStyle.control }">
|
||||
<span>{{ nc.goodsNameStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">销售价</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.mainControl = !nc.priceStyle.mainControl" :class="{ 'layui-form-checked' : nc.priceStyle.mainControl }">
|
||||
<span>{{ nc.priceStyle.mainControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- 样式编辑 -->
|
||||
<template slot="edit-style">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<div class="template-edit-title">
|
||||
<h3>商品样式</h3>
|
||||
|
||||
<div class="layui-form-item tag-wrap">
|
||||
<label class="layui-form-label sm">边框</label>
|
||||
<div class="layui-input-block">
|
||||
<div v-for="(item,ornamentIndex) in nc.tempData.ornamentList" :key="ornamentIndex" @click="nc.ornament.type=item.type" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.ornament.type==item.type) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.ornament.type == item.type ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color v-if="nc.ornament.type != 'default'" :data="{ field : 'color', 'label' : '边框颜色', parent : 'ornament', defaultColor : '#EDEDED' }"></color>
|
||||
|
||||
<slide :data="{ field : 'imgAroundRadius', label: '图片圆角', min:0, max: 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.template == 'horizontal-slide'">
|
||||
<label class="layui-form-label sm">滚动方式</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.slideMode = 'scroll' " :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.slideMode == 'scroll') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.slideMode == 'scroll' ? "" : "" }}</i>
|
||||
<div>平移</div>
|
||||
</div>
|
||||
<div @click="nc.slideMode = 'slide' " :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.slideMode == 'slide') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.slideMode == 'slide' ? "" : "" }}</i>
|
||||
<div>切屏</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.goodsNameStyle.control">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.fontWeight = !nc.goodsNameStyle.fontWeight" :class="{ 'layui-form-checked' : nc.goodsNameStyle.fontWeight }">
|
||||
<span>加粗</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
<div v-for="(item,nameLineIndex) in nc.tempData.nameLineModeList" :key="nameLineIndex" @click="nc.nameLineMode=item.value" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.nameLineMode==item.value) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.nameLineMode == item.value ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color :data="{ field : 'elementBgColor', 'label' : '商品背景' }"></color>
|
||||
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'topElementAroundRadius', label : '上圆角', max : 50 }"></slide>
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'bottomElementAroundRadius', label : '下圆角', max : 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="nc.theme == 'diy'">
|
||||
<color :data="{ field : 'color', 'label' : '商品名称', parent : 'goodsNameStyle', defaultColor : '#303133' }"></color>
|
||||
<color :data="{ field : 'mainColor', 'label' : '销售价', parent : 'priceStyle', defaultColor : '#FF6A00' }"></color>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support && nc.btnStyle.control">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<slide :data="{ field : 'aroundRadius', label: '圆角', min:0, max: 50, parent: 'btnStyle' }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.btnStyle.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.btnStyle.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="nc.btnStyle.theme == 'diy'">
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '背景颜色', parent : 'btnStyle', defaultColor : '#FF7B1D,#FF1544' }"></color>
|
||||
<color :data="{ field : 'textColor', 'label' : '文字颜色', parent : 'btnStyle', defaultColor : '#FFFFFF' }"></color>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- 资源 -->
|
||||
<template slot="resource">
|
||||
<js>
|
||||
var presaleResourcePath = "{$resource_path}"; // http路径
|
||||
var presaleRelativePath = "{$relative_path}"; // 相对路径
|
||||
</js>
|
||||
<css src="{$resource_path}/css/design.css"></css>
|
||||
<js src="{$resource_path}/js/design.js"></js>
|
||||
</template>
|
||||
|
||||
</nc-component>
|
||||
121
addon/presale/component/view/presale/js/design.js
Executable file
121
addon/presale/component/view/presale/js/design.js
Executable file
@@ -0,0 +1,121 @@
|
||||
var presaleListHtml = '<div style="display:none;"></div>';
|
||||
|
||||
Vue.component("presale-list-sources", {
|
||||
template: presaleListHtml,
|
||||
data: function () {
|
||||
return {
|
||||
data: this.$parent.data,
|
||||
goodsSources: {
|
||||
initial: {
|
||||
text: "默认",
|
||||
icon: "iconmofang"
|
||||
},
|
||||
diy: {
|
||||
text: "手动选择",
|
||||
icon: "iconshoudongxuanze"
|
||||
},
|
||||
},
|
||||
templateList: {
|
||||
"row1-of1": {
|
||||
text: "单列",
|
||||
icon: "iconiPhone86",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
},
|
||||
],
|
||||
},
|
||||
"horizontal-slide": {
|
||||
text: "横向滑动",
|
||||
icon: "iconshangpinliebiaohengxianghuadong",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: false, // 是否支持按钮
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
ornamentList: [
|
||||
{
|
||||
type: 'default',
|
||||
text: '默认',
|
||||
},
|
||||
{
|
||||
type: 'shadow',
|
||||
text: '投影',
|
||||
},
|
||||
{
|
||||
type: 'stroke',
|
||||
text: '描边',
|
||||
},
|
||||
],
|
||||
nameLineModeList: [
|
||||
{
|
||||
text: "单行",
|
||||
value: "single"
|
||||
},
|
||||
{
|
||||
text: "多行",
|
||||
value: "multiple"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
if (!this.$parent.data.verify) this.$parent.data.verify = [];
|
||||
this.$parent.data.verify.push(this.verify);//加载验证方法
|
||||
|
||||
this.$parent.data.ignore = ['textColor']; //加载忽略内容 -- 其他设置中的属性设置
|
||||
this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
|
||||
|
||||
var previewList = {};
|
||||
for (var i = 1; i < 4; i++) {
|
||||
previewList["goods_id_" + ns.gen_non_duplicate(i)] = {
|
||||
goods_name: "预售商品",
|
||||
discount_price: (Math.random() * 100 * i + 10).toFixed(2), // 随机价格
|
||||
};
|
||||
}
|
||||
|
||||
// 组件所需的临时数据
|
||||
this.$parent.data.tempData = {
|
||||
goodsSources: this.goodsSources,
|
||||
templateList: this.templateList,
|
||||
ornamentList: this.ornamentList,
|
||||
nameLineModeList: this.nameLineModeList,
|
||||
previewList: previewList,
|
||||
methods: {
|
||||
addGoods: this.addGoods,
|
||||
selectTemplate: this.selectTemplate
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
verify: function (index) {
|
||||
var res = {code: true, message: ""};
|
||||
if (vue.data[index].sources === 'diy' && vue.data[index].goodsId.length === 0) {
|
||||
res.code = false;
|
||||
res.message = "请选择商品";
|
||||
}
|
||||
return res;
|
||||
},
|
||||
addGoods: function () {
|
||||
var self = this;
|
||||
goodsSelect(function (res) {
|
||||
self.$parent.data.goodsId = res;
|
||||
}, self.$parent.data.goodsId, {mode: "spu", promotion: "presale", disabled: 0, post: ns.appModule});
|
||||
},
|
||||
selectTemplate(template, item) {
|
||||
if (template) {
|
||||
this.$parent.data.template = template;
|
||||
item = this.templateList[template].styleList[0];
|
||||
}
|
||||
this.$parent.data.style = item.value;
|
||||
this.$parent.data.btnStyle.support = item.cartSupport;
|
||||
this.$parent.data.btnStyle.control = item.cartSupport;
|
||||
},
|
||||
}
|
||||
});
|
||||
84
addon/presale/config/diy_view.php
Executable file
84
addon/presale/config/diy_view.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [
|
||||
[
|
||||
'name' => 'Presale',
|
||||
'title' => '预售',
|
||||
'type' => 'PROMOTION',
|
||||
'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"ornament":{"type":"default","color":"#EDEDED"},"nameLineMode":"single","template":"horizontal-slide","goodsMarginType":"default","goodsMarginNum":10,"btnStyle":{"text":"立即抢购","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":false,"support":false,"bgColorStart":"#FF7B1D","bgColorEnd":"#FF1544"},"imgAroundRadius":5,"slideMode":"scroll","theme":"default","goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false},"priceStyle":{"mainColor":"#FF1544","mainControl":true},"titleStyle":{"isShow":true,"leftStyle":"text","leftImg":"","style":"style-1","styleName":"风格1","leftText":"限时秒杀","fontSize":16,"fontWeight":true,"textColor":"#303133","bgColorStart":"#FFFFFF","bgColorEnd":"#FFFFFF","more":"查看更多","moreColor":"#999999","moreFontSize":12}}',
|
||||
'sort' => '30007',
|
||||
'support_diy_view' => '',
|
||||
'max_count' => 0,
|
||||
'icon' => 'iconfont iconyushou1',
|
||||
]
|
||||
],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [
|
||||
[
|
||||
'name' => 'GOODS_BOOKING',
|
||||
'title' => '商品预售',
|
||||
'parent' => 'MARKETING_LINK',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'sort' => 0,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PRESALE_PREFECTURE',
|
||||
'title' => '预售专区',
|
||||
'wap_url' => '/pages_promotion/presale/list',
|
||||
'web_url' => '',
|
||||
'sort' => 1
|
||||
],
|
||||
[
|
||||
'name' => 'MAPRESALE_PREFECTURE',
|
||||
'title' => '我的预售',
|
||||
'wap_url' => '/pages_promotion/presale/order_list',
|
||||
'web_url' => '',
|
||||
'sort' => 2
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PRESALE_GOODS',
|
||||
'title' => '预售商品',
|
||||
'parent' => 'COMMODITY',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'child_list' => []
|
||||
]
|
||||
],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
79
addon/presale/config/event.php
Executable file
79
addon/presale/config/event.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\presale\event\ShowPromotion',
|
||||
],
|
||||
|
||||
'PromotionType' => [
|
||||
'addon\presale\event\PromotionType',
|
||||
],
|
||||
|
||||
//关闭预售
|
||||
'ClosePresale' => [
|
||||
'addon\presale\event\ClosePresale',
|
||||
],
|
||||
|
||||
//开启预售
|
||||
'OpenPresale' => [
|
||||
'addon\presale\event\OpenPresale',
|
||||
],
|
||||
|
||||
// 商品营销活动类型
|
||||
'GoodsPromotionType' => [
|
||||
'addon\presale\event\GoodsPromotionType',
|
||||
],
|
||||
//定金订单关闭
|
||||
'CronDepositOrderClose' => [
|
||||
'addon\presale\event\DepositOrderClose'
|
||||
],
|
||||
//定金支付回调地址
|
||||
'DepositOrderPayNotify' => [
|
||||
'addon\presale\event\DepositOrderPayNotify'
|
||||
],
|
||||
//尾款支付回调地址
|
||||
'FinalOrderPayNotify' => [
|
||||
'addon\presale\event\FinalOrderPayNotify'
|
||||
],
|
||||
//预售订单退款
|
||||
'AddonOrderRefund' => [
|
||||
'addon\presale\event\AddonOrderRefund'
|
||||
],
|
||||
// 商品列表
|
||||
'GoodsListPromotion' => [
|
||||
'addon\presale\event\GoodsListPromotion',
|
||||
],
|
||||
// 商品分类
|
||||
'GoodsListCategoryIds' => [
|
||||
'addon\presale\event\GoodsListCategoryIds',
|
||||
],
|
||||
|
||||
'MemberAccountFromType' => [
|
||||
'addon\presale\event\MemberAccountFromType',
|
||||
],
|
||||
|
||||
//订单营销类型
|
||||
'OrderPromotionType' => [
|
||||
'addon\presale\event\OrderPromotionType',
|
||||
],
|
||||
|
||||
//判断sku是否参与预售
|
||||
'IsJoinPresale' => [
|
||||
'addon\presale\event\IsJoinPresale',
|
||||
],
|
||||
|
||||
//订单尾款结束自动退款
|
||||
'CronRefundOrderDepositClose' => [
|
||||
'addon\presale\event\CronRefundOrderDepositClose',
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/presale/config/info.php
Executable file
20
addon/presale/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'presale',
|
||||
'title' => '商品预售',
|
||||
'description' => '商品预售活动',
|
||||
'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
111
addon/presale/config/menu_shop.php
Executable file
111
addon/presale/config/menu_shop.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 店铺端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE',
|
||||
'title' => '商品预售',
|
||||
'url' => 'presale://shop/presale/lists',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'picture' => 'addon/presale/shop/view/public/img/distribution_new.png',
|
||||
'picture_selected' => 'addon/presale/shop/view/public/img/distribution_select.png',
|
||||
'is_show' => 1,
|
||||
'sort' => 100,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_LISTS',
|
||||
'title' => '预售商品',
|
||||
'url' => 'presale://shop/presale/lists',
|
||||
'is_show' => 1,
|
||||
'sort' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_DETAIL',
|
||||
'title' => '预售详情',
|
||||
'url' => 'presale://shop/presale/detail',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ADD',
|
||||
'title' => '添加预售',
|
||||
'url' => 'presale://shop/presale/add',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_EDIT',
|
||||
'title' => '编辑预售',
|
||||
'url' => 'presale://shop/presale/edit',
|
||||
'sort' => 2,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_DELETE',
|
||||
'title' => '删除预售',
|
||||
'url' => 'presale://shop/presale/delete',
|
||||
'sort' => 3,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ORDER',
|
||||
'title' => '预售订单',
|
||||
'url' => 'presale://shop/order/lists',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'sort' => 2,
|
||||
'parent' => 'ORDER_MANAGE',
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ORDER_DETAIL',
|
||||
'title' => '订单详情',
|
||||
'url' => 'presale://shop/order/detail',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ORDER_REFUND',
|
||||
'title' => '退款订单',
|
||||
'url' => 'presale://shop/refund/lists',
|
||||
'is_show' => 1,
|
||||
'sort' => 3,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ORDER_REFUND_DETAIL',
|
||||
'title' => '退款详情',
|
||||
'url' => 'presale://shop/refund/detail',
|
||||
'is_show' => 0,
|
||||
'sort' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ORDER_REFUND_AGREE',
|
||||
'title' => '同意退款',
|
||||
'url' => 'presale://shop/refund/agree',
|
||||
'is_show' => 0,
|
||||
'sort' => 2,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PRESALE_ORDER_REFUND_REFUSE',
|
||||
'title' => '拒绝退款',
|
||||
'url' => 'presale://shop/refund/refuse',
|
||||
'is_show' => 0,
|
||||
'sort' => 3,
|
||||
'type' => 'button',
|
||||
],
|
||||
|
||||
]
|
||||
],
|
||||
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
1
addon/presale/data/install.sql
Executable file
1
addon/presale/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/presale/data/uninstall.sql
Executable file
1
addon/presale/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
31
addon/presale/event/AddonOrderRefund.php
Executable file
31
addon/presale/event/AddonOrderRefund.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\PresaleOrderRefund;
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*/
|
||||
class AddonOrderRefund
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
if ($params[ 'promotion_type' ] == 'presale') {
|
||||
$presale = new PresaleOrderRefund();
|
||||
$res = $presale->refundPresaleOrder($params[ 'order_no' ], $params[ 'is_deposit_back' ], $params[ 'refund_money_type' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
addon/presale/event/ClosePresale.php
Executable file
30
addon/presale/event/ClosePresale.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\Presale;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class ClosePresale
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$presale = new Presale();
|
||||
$res = $presale->cronClosePresale($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
31
addon/presale/event/CronRefundOrderDepositClose.php
Executable file
31
addon/presale/event/CronRefundOrderDepositClose.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
|
||||
/**
|
||||
* 订单尾款结束自动退款
|
||||
*/
|
||||
class CronRefundOrderDepositClose
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$presale_order_model = new PresaleOrderCommon();
|
||||
$res = $presale_order_model->cronRefundOrderDepositClose($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
31
addon/presale/event/DepositOrderClose.php
Executable file
31
addon/presale/event/DepositOrderClose.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
|
||||
/**
|
||||
* 定金订单关闭
|
||||
*/
|
||||
class DepositOrderClose
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$presale_order_model = new PresaleOrderCommon();
|
||||
$res = $presale_order_model->cronDepositOrderClose($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
31
addon/presale/event/DepositOrderPayNotify.php
Executable file
31
addon/presale/event/DepositOrderPayNotify.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
|
||||
/**
|
||||
* 定金支付回调
|
||||
*/
|
||||
class DepositOrderPayNotify
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$presale_order_model = new PresaleOrderCommon();
|
||||
$res = $presale_order_model->depositOrderOnlinePay($params);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
31
addon/presale/event/FinalOrderPayNotify.php
Executable file
31
addon/presale/event/FinalOrderPayNotify.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
|
||||
/**
|
||||
* 尾款支付回调
|
||||
*/
|
||||
class FinalOrderPayNotify
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$presale_order_model = new PresaleOrderCommon();
|
||||
$res = $presale_order_model->finalOrderOnlinePay($params);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
42
addon/presale/event/GoodsListCategoryIds.php
Executable file
42
addon/presale/event/GoodsListCategoryIds.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\Presale;
|
||||
|
||||
/**
|
||||
* 商品分类id
|
||||
*/
|
||||
class GoodsListCategoryIds
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'presale') return [];
|
||||
|
||||
$condition[] = [
|
||||
[ 'pp.site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
];
|
||||
|
||||
$model = new Presale();
|
||||
$res = $model->getGoodsCategoryIds($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
59
addon/presale/event/GoodsListPromotion.php
Executable file
59
addon/presale/event/GoodsListPromotion.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\Presale;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsListPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'presale') return [];
|
||||
|
||||
$condition[] = [
|
||||
[ 'pp.site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'pp.status', '=', 1 ]
|
||||
];
|
||||
if ($param[ 'promotion_name' ]) {
|
||||
$condition[] = [ 'pp.presale_name', 'like', '%' . $param[ 'promotion_name' ] . '%' ];
|
||||
}
|
||||
if (!empty($param[ 'goods_name' ])) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $param[ 'goods_name' ] . '%' ];
|
||||
}
|
||||
if (!empty($param[ 'select_type' ]) && $param[ 'select_type' ] == 'selected' && isset($param[ 'goods_ids' ])) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $param[ 'goods_ids' ] ];
|
||||
}
|
||||
if (!empty($param[ 'category_id' ])) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $param[ 'category_id' ] . ',%' ];
|
||||
}
|
||||
if (!empty($param[ 'label_id' ])) {
|
||||
$condition[] = [ 'g.label_id', '=', $param[ 'label_id' ] ];
|
||||
}
|
||||
if (!empty($param[ 'goods_class' ])) {
|
||||
$condition[] = [ 'g.goods_class', '=', $param[ 'goods_class' ] ];
|
||||
}
|
||||
$model = new Presale();
|
||||
$list = $model->getPresaleGoodsPageList($condition, $param[ 'page' ], $param[ 'page_size' ], 'pp.presale_id desc');
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
30
addon/presale/event/GoodsPromotionType.php
Executable file
30
addon/presale/event/GoodsPromotionType.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class GoodsPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ 'name' => '商品预售', 'short' => '预', 'type' => 'presale', 'color' => '#4CB130', 'url' => 'presale://shop/presale/lists' ];
|
||||
}
|
||||
}
|
||||
26
addon/presale/event/Install.php
Executable file
26
addon/presale/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
41
addon/presale/event/IsJoinPresale.php
Executable file
41
addon/presale/event/IsJoinPresale.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\Presale;
|
||||
|
||||
/**
|
||||
* 是否参与预售
|
||||
*/
|
||||
class IsJoinPresale
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
if(isset($params['goods_id']))
|
||||
{
|
||||
$presale = new Presale();
|
||||
$res = $presale->isJoinPresaleByGoodsId($params[ 'goods_id' ]);
|
||||
}elseif (isset($params['sku_id'])) {
|
||||
$presale = new Presale();
|
||||
$res = $presale->isJoinPresaleBySkuId($params[ 'sku_id' ]);
|
||||
}elseif (isset($params['sku_ids'])) {
|
||||
$presale = new Presale();
|
||||
$res = $presale->isJoinPresaleBySkuIds($params[ 'sku_ids' ]);
|
||||
}else{
|
||||
$res = error();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
45
addon/presale/event/MemberAccountFromType.php
Executable file
45
addon/presale/event/MemberAccountFromType.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
/**
|
||||
* 会员账户变化来源类型
|
||||
*/
|
||||
class MemberAccountFromType
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$from_type = [
|
||||
'balance' => [
|
||||
'presale_order' => [
|
||||
'type_name' => '预售订单',
|
||||
'type_url' => '',
|
||||
],
|
||||
'presale_deposit_refund' => [ 'type_name' => '预售定金退还', 'type_url' => '' ],
|
||||
'presale_refund' => [ 'type_name' => '预售订单退还', 'type_url' => '' ],
|
||||
],
|
||||
'balance_money' => [
|
||||
'presale_order' => [
|
||||
'type_name' => '预售订单',
|
||||
'type_url' => '',
|
||||
]
|
||||
]
|
||||
];
|
||||
if ($data == '') {
|
||||
return $from_type;
|
||||
} else {
|
||||
return $from_type[$data] ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
30
addon/presale/event/OpenPresale.php
Executable file
30
addon/presale/event/OpenPresale.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use addon\presale\model\Presale;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class OpenPresale
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$presale = new Presale();
|
||||
$res = $presale->cronOpenPresale($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
27
addon/presale/event/OrderPromotionType.php
Executable file
27
addon/presale/event/OrderPromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
/**
|
||||
* 订单营销活动类型
|
||||
*/
|
||||
class OrderPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 订单营销活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "预售", "type" => "presale" ];
|
||||
}
|
||||
}
|
||||
30
addon/presale/event/PromotionType.php
Executable file
30
addon/presale/event/PromotionType.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "商品预售", "type" => "presale" ];
|
||||
}
|
||||
}
|
||||
100
addon/presale/event/ShowPromotion.php
Executable file
100
addon/presale/event/ShowPromotion.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'presale',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '商品预售',
|
||||
//展示介绍
|
||||
'description' => '定金膨胀引流预热',
|
||||
//展示图标
|
||||
'icon' => 'addon/presale/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'presale://shop/presale/lists',
|
||||
'summary' => $this->summary($params)
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("promotion_presale")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$join = [
|
||||
[ 'goods g', 'p.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
$list = model("promotion_presale")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'p.site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'p.status', '<>', 3 ],
|
||||
[ 'p.status', '<>', 4 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
], 'p.presale_name as promotion_name,p.presale_id as promotion_id,p.start_time,p.end_time', '', 'p', $join, 'p.presale_name');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#E066FF'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/presale/event/UnInstall.php
Executable file
26
addon/presale/event/UnInstall.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\presale\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/presale/icon.png
Executable file
BIN
addon/presale/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
363
addon/presale/model/Poster.php
Executable file
363
addon/presale/model/Poster.php
Executable file
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model;
|
||||
|
||||
use addon\postertemplate\model\PosterTemplate as PosterTemplateModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\upload\Upload;
|
||||
use app\model\web\Config;
|
||||
use extend\Poster as PosterExtend;
|
||||
|
||||
/**
|
||||
* 海报生成类
|
||||
*/
|
||||
class Poster extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 商品海报
|
||||
*/
|
||||
public function goods($app_type, $page, $qrcode_param, $promotion_type, $site_id)
|
||||
{
|
||||
try {
|
||||
$goods_info = $this->getGoodsInfo($qrcode_param[ 'id' ]);
|
||||
if (empty($goods_info)) return $this->error('未获取到商品信息');
|
||||
//判断海报是否存在或停用
|
||||
$template_info = $this->getTemplateInfo($goods_info[ 'template_id' ]);
|
||||
$qrcode_info = $this->getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id);
|
||||
if ($qrcode_info[ 'code' ] < 0) return $qrcode_info;
|
||||
|
||||
$site_model = new Site();
|
||||
$condition = array (
|
||||
[ "site_id", "=", $site_id ]
|
||||
);
|
||||
$site_info = $site_model->getSiteInfo($condition);
|
||||
|
||||
if (!empty($qrcode_param[ 'source_member' ])) {
|
||||
$member_info = $this->getMemberInfo($qrcode_param[ 'source_member' ]);
|
||||
}
|
||||
$upload_config_model = new Config();
|
||||
$upload_config_result = $upload_config_model->getDefaultImg($site_id);
|
||||
|
||||
if (empty($goods_info[ 'template_id' ]) || empty($template_info) || $template_info[ 'template_status' ] == 0) {
|
||||
$poster_width = 720;
|
||||
$poster_height = 1150;
|
||||
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
|
||||
$option = [
|
||||
[
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [255, 255, 255]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品图
|
||||
'data' => [
|
||||
img($goods_info['sku_image'], 'mid'),
|
||||
50,
|
||||
165,
|
||||
620,
|
||||
620,
|
||||
'square',
|
||||
true,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info['sku_name'],
|
||||
22,
|
||||
[35, 35, 35],
|
||||
50,
|
||||
915,
|
||||
360,
|
||||
2,
|
||||
true,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品二维码
|
||||
'data' => [
|
||||
$qrcode_info['data']['path'],
|
||||
435,
|
||||
825,
|
||||
240,
|
||||
240,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入提示
|
||||
'data' => [
|
||||
'长按识别二维码',
|
||||
19,
|
||||
[102, 102, 102],
|
||||
465,
|
||||
1110,
|
||||
490,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'定金¥' . $goods_info[ 'presale_deposit' ] . '可抵¥' . $goods_info[ 'presale_price' ],
|
||||
20,
|
||||
[255, 0, 0],
|
||||
50,
|
||||
862,
|
||||
490,
|
||||
2,
|
||||
true,
|
||||
1
|
||||
]
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$condition = [
|
||||
[ 'template_id', '=', $goods_info[ 'template_id' ] ],
|
||||
[ 'site_id', '=', $site_id ]
|
||||
];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$poster_data = $poster_template_model->getPosterTemplateInfo($condition);
|
||||
$poster_data[ 'data' ][ 'template_json' ] = json_decode($poster_data[ 'data' ][ 'template_json' ], true);
|
||||
$poster_width = 720;
|
||||
$poster_height = 1280;
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$fontRate = 0.725; // 20px 等于 14.5磅,换算比率 1px = 0.725磅
|
||||
$option = [
|
||||
[
|
||||
'action' => 'imageText', // 写入店铺名称
|
||||
'data' => [
|
||||
$site_info[ 'data' ][ 'site_name' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'store_name_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'store_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 店铺logo
|
||||
'data' => [
|
||||
!empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : getUrl() . '/app/shop/view/public/img/shop_logo.png',
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_height' ] * 2,
|
||||
'square',
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品图
|
||||
'data' => [
|
||||
$goods_info[ 'sku_image' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info[ 'sku_name' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_name_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_width' ] * 2,
|
||||
1,//文本行数 $poster_data['data']['template_json']['goods_name_height']*2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品二维码
|
||||
'data' => [
|
||||
$qrcode_info[ 'data' ][ 'path' ],
|
||||
$poster_data[ 'data' ][ 'qrcode_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_height' ] * 2,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'定金¥' . $goods_info[ 'presale_deposit' ] . '可抵¥' . $goods_info[ 'presale_price' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_price_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
if (!empty($member_info)) {
|
||||
$member_option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入用户头像
|
||||
'data' => [
|
||||
!empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
$member_info[ 'nickname' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'nickname_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_height' ] * 2,
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
$option = array_merge($option, $member_option);
|
||||
}
|
||||
if (!empty($poster_data[ 'data' ][ 'background' ])) {
|
||||
list($width, $height, $type, $attr) = getimagesize(img($poster_data[ 'data' ][ 'background' ]));
|
||||
$back_ground = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入背景图
|
||||
'data' => [
|
||||
img($poster_data[ 'data' ][ 'background' ]),
|
||||
0,
|
||||
0,
|
||||
$poster_width,
|
||||
$poster_height,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$back_ground = [
|
||||
[
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [ 255, 255, 255 ]
|
||||
],
|
||||
];
|
||||
}
|
||||
$ground = [
|
||||
[
|
||||
'action' => 'setBackground',
|
||||
'data' => [ 255, 255, 255 ]
|
||||
]
|
||||
];
|
||||
$option = array_merge($ground, $back_ground, $option);
|
||||
}
|
||||
$option_res = $poster->create($option);
|
||||
if (is_array($option_res)) return $option_res;
|
||||
|
||||
$res = $option_res->jpeg('upload/poster/goods', 'goods_' . $promotion_type . '_' . $goods_info[ 'presale_id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . time() . '_' . $app_type);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$upload = new Upload($site_id);
|
||||
$cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
|
||||
if ($cloud_res[ 'code' ] >= 0) {
|
||||
return $this->success([ "path" => $cloud_res[ 'data' ] ]);
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param unknown $member_id
|
||||
*/
|
||||
private function getMemberInfo($member_id)
|
||||
{
|
||||
$info = model('member')->getInfo([ 'member_id' => $member_id ], 'nickname,headimg');
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品信息
|
||||
* @param unknown $sku_id
|
||||
*/
|
||||
private function getGoodsInfo($id)
|
||||
{
|
||||
$join = [
|
||||
[ 'goods_sku sku', 'pbg.sku_id = sku.sku_id', 'inner' ],
|
||||
];
|
||||
$field = 'pbg.presale_id,pbg.presale_deposit,pbg.presale_price,sku.sku_name,sku.sku_image,sku.template_id';
|
||||
$info = model('promotion_presale_goods')->getInfo([ 'pbg.presale_id' => $id ], $field, 'pbg', $join);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品二维码
|
||||
* @param unknown $app_type 请求类型
|
||||
* @param unknown $page uniapp页面路径
|
||||
* @param unknown $qrcode_param 二维码携带参数
|
||||
* @param string $promotion_type 活动类型 null为无活动
|
||||
*/
|
||||
private function getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id)
|
||||
{
|
||||
$res = event('Qrcode', [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => $app_type,
|
||||
'type' => 'create',
|
||||
'data' => $qrcode_param,
|
||||
'page' => $page,
|
||||
'qrcode_path' => 'upload/qrcode/goods',
|
||||
'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . $site_id,
|
||||
], true);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报信息
|
||||
* @param unknown $template_id
|
||||
*/
|
||||
private function getTemplateInfo($template_id)
|
||||
{
|
||||
$info = model('poster_template')->getInfo([ 'template_id' => $template_id ], 'template_id,template_status');
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
896
addon/presale/model/Presale.php
Executable file
896
addon/presale/model/Presale.php
Executable file
@@ -0,0 +1,896 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\goods\Goods;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\system\Cron;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 预售活动
|
||||
*/
|
||||
class Presale extends BaseModel
|
||||
{
|
||||
|
||||
private $status = [
|
||||
0 => '未开始',
|
||||
1 => '进行中',
|
||||
2 => '已结束',
|
||||
3 => '已关闭'
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取预售活动状态
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleStatus()
|
||||
{
|
||||
return $this->success($this->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加预售
|
||||
* @param $presale_data
|
||||
* @param $goods
|
||||
* @param $sku_list
|
||||
* @return array
|
||||
*/
|
||||
public function addPresale($presale_data, $goods, $sku_list)
|
||||
{
|
||||
if (empty($goods[ 'sku_ids' ])) {
|
||||
return $this->error('', '该活动至少需要一个商品参与');
|
||||
}
|
||||
$presale_data[ 'create_time' ] = time();
|
||||
|
||||
//查询该商品是否存在预售
|
||||
$presale_info = model('promotion_presale_goods')->getInfo(
|
||||
[
|
||||
[ 'ppg.site_id', '=', $presale_data[ 'site_id' ] ],
|
||||
[ 'pp.status', 'in', '0,1' ],
|
||||
[ 'ppg.goods_id', 'in', $goods[ 'goods_ids' ] ],
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` > ' . $presale_data[ 'end_time' ] . ' and `start_time` > ' . $presale_data[ 'start_time' ] . ' ) or (`end_time` < ' . $presale_data[ 'start_time' ] . ' and `end_time` < ' . $presale_data[ 'end_time' ] . '))') ]
|
||||
], 'ppg.id', 'ppg', [ [ 'promotion_presale pp', 'pp.presale_id = ppg.presale_id', 'left' ] ]
|
||||
);
|
||||
if (!empty($presale_info)) {
|
||||
return $this->error('', "当前商品在当前时间段内已经存在预售活动");
|
||||
}
|
||||
|
||||
if (time() > $presale_data[ 'end_time' ]) {
|
||||
return $this->error('', '当前时间不能大于结束时间');
|
||||
}
|
||||
if ($presale_data[ 'start_time' ] <= time()) {
|
||||
$presale_data[ 'status' ] = 1;
|
||||
$presale_data[ 'status_name' ] = $this->status[ 1 ];
|
||||
} else {
|
||||
$presale_data[ 'status' ] = 0;
|
||||
$presale_data[ 'status_name' ] = $this->status[ 0 ];
|
||||
}
|
||||
model("promotion_presale")->startTrans();
|
||||
try {
|
||||
|
||||
foreach ($goods[ 'goods_ids' ] as $goods_id) {
|
||||
|
||||
//添加预售活动
|
||||
$presale_data[ 'goods_id' ] = $goods_id;
|
||||
$presale_id = model("promotion_presale")->add($presale_data);
|
||||
|
||||
$presale_stock = 0;
|
||||
|
||||
$sku_list_data = [];
|
||||
foreach ($sku_list as $k => $sku) {
|
||||
|
||||
if ($sku[ 'goods_id' ] == $goods_id) {
|
||||
|
||||
$presale_stock += $sku[ 'presale_stock' ];//总库存
|
||||
$sku_list_data[] = [
|
||||
'site_id' => $presale_data[ 'site_id' ],
|
||||
'presale_id' => $presale_id,
|
||||
'goods_id' => $goods_id,
|
||||
'sku_id' => $sku[ 'sku_id' ],
|
||||
'presale_stock' => $sku[ 'presale_stock' ],
|
||||
'presale_deposit' => $sku[ 'presale_deposit' ],
|
||||
'presale_price' => $sku[ 'presale_price' ],
|
||||
];
|
||||
}
|
||||
}
|
||||
array_multisort(array_column($sku_list_data, 'presale_deposit'), SORT_ASC, $sku_list_data);
|
||||
model('promotion_presale_goods')->addList($sku_list_data);
|
||||
|
||||
model('promotion_presale')->update(
|
||||
[
|
||||
'presale_stock' => $presale_stock,
|
||||
'presale_deposit' => $sku_list_data[ 0 ][ 'presale_deposit' ],
|
||||
'presale_price' => $sku_list_data[ 0 ][ 'presale_price' ],
|
||||
'sku_id' => $sku_list_data[ 0 ][ 'sku_id' ]
|
||||
],
|
||||
[ [ 'presale_id', '=', $presale_id ] ]
|
||||
);
|
||||
|
||||
$cron = new Cron();
|
||||
if ($presale_data[ 'status' ] == 1) {
|
||||
$goods = new Goods();
|
||||
$goods->modifyPromotionAddon($goods_id, [ 'presale' => $presale_id ]);
|
||||
$cron->addCron(1, 0, "预售活动关闭", "ClosePresale", $presale_data[ 'end_time' ], $presale_id);
|
||||
} else {
|
||||
$cron->addCron(1, 0, "预售活动开启", "OpenPresale", $presale_data[ 'start_time' ], $presale_id);
|
||||
$cron->addCron(1, 0, "预售活动关闭", "ClosePresale", $presale_data[ 'end_time' ], $presale_id);
|
||||
}
|
||||
}
|
||||
|
||||
model('promotion_presale')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑预售
|
||||
* @param $presale_data
|
||||
* @param $goods
|
||||
* @param $sku_list
|
||||
* @return array
|
||||
*/
|
||||
public function editPresale($presale_data, $goods, $sku_list)
|
||||
{
|
||||
if (empty($goods[ 'sku_ids' ])) {
|
||||
return $this->error('', '该活动至少需要一个商品参与');
|
||||
}
|
||||
//查询该商品是否存在预售
|
||||
$presale_info = model('promotion_presale_goods')->getInfo(
|
||||
[
|
||||
[ 'ppg.site_id', '=', $presale_data[ 'site_id' ] ],
|
||||
[ 'pp.status', 'in', '0,1' ],
|
||||
[ 'ppg.presale_id', '<>', $presale_data[ 'presale_id' ] ],
|
||||
[ 'ppg.sku_id', 'in', $goods[ 'sku_ids' ] ],
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` > ' . $presale_data[ 'end_time' ] . ' and `start_time` > ' . $presale_data[ 'start_time' ] . ' ) or (`end_time` < ' . $presale_data[ 'start_time' ] . ' and `end_time` < ' . $presale_data[ 'end_time' ] . '))') ]
|
||||
], 'ppg.id', 'ppg', [ [ 'promotion_presale pp', 'pp.presale_id = ppg.presale_id', 'left' ] ]
|
||||
);
|
||||
if (!empty($presale_info)) {
|
||||
return $this->error('', "当前商品在当前时间段内已经存在预售活动");
|
||||
}
|
||||
|
||||
$presale_count = model("promotion_presale")->getCount([ [ 'presale_id', '=', $presale_data[ 'presale_id' ] ], [ 'site_id', '=', $presale_data[ 'site_id' ] ] ]);
|
||||
if ($presale_count == 0) {
|
||||
return $this->error('', '该预售活动不存在');
|
||||
}
|
||||
|
||||
$cron = new Cron();
|
||||
if (time() > $presale_data[ 'end_time' ]) {
|
||||
return $this->error('', '当前时间不能大于结束时间');
|
||||
}
|
||||
if ($presale_data[ 'start_time' ] <= time()) {
|
||||
$presale_data[ 'status' ] = 1;
|
||||
$presale_data[ 'status_name' ] = $this->status[ 1 ];
|
||||
} else {
|
||||
$presale_data[ 'status' ] = 0;
|
||||
$presale_data[ 'status_name' ] = $this->status[ 0 ];
|
||||
}
|
||||
|
||||
$presale_data[ 'modify_time' ] = time();
|
||||
model('promotion_presale')->startTrans();
|
||||
try {
|
||||
$presale_stock = 0;
|
||||
$sku_list_data = [];
|
||||
foreach ($sku_list as $k => $sku) {
|
||||
|
||||
$count = model('promotion_presale_goods')->getCount([ [ 'sku_id', '=', $sku[ 'sku_id' ] ], [ 'presale_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
$is_delete = $sku[ 'is_delete' ];
|
||||
unset($sku[ 'is_delete' ]);
|
||||
if ($is_delete == 2) {//是否参与 1参与 2不参与
|
||||
if ($count) {
|
||||
model('promotion_presale_goods')->delete([ [ 'sku_id', '=', $sku[ 'sku_id' ] ], [ 'presale_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
}
|
||||
} else {
|
||||
|
||||
$presale_stock += $sku[ 'presale_stock' ];//总库存
|
||||
$sku_data = [
|
||||
'site_id' => $presale_data[ 'site_id' ],
|
||||
'presale_id' => $presale_data[ 'presale_id' ],
|
||||
'goods_id' => $goods[ 'goods_id' ],
|
||||
'sku_id' => $sku[ 'sku_id' ],
|
||||
'presale_stock' => $sku[ 'presale_stock' ],
|
||||
'presale_deposit' => $sku[ 'presale_deposit' ],
|
||||
'presale_price' => $sku[ 'presale_price' ],
|
||||
];
|
||||
|
||||
if ($count > 0) {
|
||||
model('promotion_presale_goods')->update($sku_data, [ [ 'sku_id', '=', $sku[ 'sku_id' ] ], [ 'presale_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
} else {
|
||||
model('promotion_presale_goods')->add($sku_data);
|
||||
}
|
||||
$sku_list_data[] = $sku_data;
|
||||
}
|
||||
}
|
||||
array_multisort(array_column($sku_list_data, 'presale_deposit'), SORT_ASC, $sku_list_data);
|
||||
model("promotion_presale")->update(
|
||||
array_merge($presale_data, [
|
||||
'presale_stock' => $presale_stock,
|
||||
'presale_deposit' => $sku_list_data[ 0 ][ 'presale_deposit' ],
|
||||
'presale_price' => $sku_list_data[ 0 ][ 'presale_price' ],
|
||||
'sku_id' => $sku_list_data[ 0 ][ 'sku_id' ]
|
||||
]),
|
||||
[ [ 'presale_id', '=', $presale_data[ 'presale_id' ] ] ]
|
||||
);
|
||||
|
||||
if ($presale_data[ 'start_time' ] <= time()) {
|
||||
|
||||
$goods_model = new Goods();
|
||||
$goods_model->modifyPromotionAddon($goods[ 'goods_id' ], [ 'presale' => $presale_data[ 'presale_id' ] ]);
|
||||
//活动商品启动
|
||||
$this->cronOpenPresale($presale_data[ 'presale_id' ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'OpenPresale' ], [ 'relate_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'ClosePresale' ], [ 'relate_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
|
||||
$cron->addCron(1, 0, "预售活动关闭", "ClosePresale", $presale_data[ 'end_time' ], $presale_data[ 'presale_id' ]);
|
||||
} else {
|
||||
$cron->deleteCron([ [ 'event', '=', 'OpenPresale' ], [ 'relate_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'ClosePresale' ], [ 'relate_id', '=', $presale_data[ 'presale_id' ] ] ]);
|
||||
|
||||
$cron->addCron(1, 0, "预售活动开启", "OpenPresale", $presale_data[ 'start_time' ], $presale_data[ 'presale_id' ]);
|
||||
$cron->addCron(1, 0, "预售活动关闭", "ClosePresale", $presale_data[ 'end_time' ], $presale_data[ 'presale_id' ]);
|
||||
}
|
||||
|
||||
model('promotion_presale')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加预售组人数及购买人数
|
||||
* @param array $data
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function editPresaleNum($data = [], $condition = [])
|
||||
{
|
||||
$res = model('promotion_presale')->update($data, $condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除预售活动
|
||||
* @param $presale_id
|
||||
* @param $site_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function deletePresale($presale_id, $site_id)
|
||||
{
|
||||
//预售信息
|
||||
$presale_info = model('promotion_presale')->getInfo([ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ], 'status');
|
||||
if ($presale_info) {
|
||||
|
||||
if ($presale_info[ 'status' ] != 1) {
|
||||
$res = model('promotion_presale')->delete([ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
if ($res) {
|
||||
//删除商品
|
||||
model('promotion_presale_goods')->delete([ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
|
||||
$cron = new Cron();
|
||||
$cron->deleteCron([ [ 'event', '=', 'OpenPresale' ], [ 'relate_id', '=', $presale_id ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'ClosePresale' ], [ 'relate_id', '=', $presale_id ] ]);
|
||||
}
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error('', '预售活动进行中,请先关闭该活动');
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error('', '预售活动不存在');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭预售活动
|
||||
* @param $presale_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function finishPresale($presale_id, $site_id)
|
||||
{
|
||||
//预售信息
|
||||
$presale_info = model('promotion_presale')->getInfo([ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ], 'status,goods_id');
|
||||
if (!empty($presale_info)) {
|
||||
|
||||
if ($presale_info[ 'status' ] != 3) {
|
||||
$res = model('promotion_presale')->update([ 'status' => 3, 'status_name' => $this->status[ 3 ] ], [ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
|
||||
$cron = new Cron();
|
||||
$cron->deleteCron([ [ 'event', '=', 'OpenPresale' ], [ 'relate_id', '=', $presale_id ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'ClosePresale' ], [ 'relate_id', '=', $presale_id ] ]);
|
||||
|
||||
$goods = new Goods();
|
||||
$goods->modifyPromotionAddon($presale_info[ 'goods_id' ], [ 'presale' => $presale_id ], true);
|
||||
|
||||
$presale_order = new PresaleOrderCommon();
|
||||
$presale_order->depositPresaleOrderClose([ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
|
||||
return $this->success($res);
|
||||
} else {
|
||||
$this->error('', '该预售活动已关闭');
|
||||
}
|
||||
} else {
|
||||
$this->error('', '该预售活动不存在');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取预售信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleInfo($condition = [], $field = '*')
|
||||
{
|
||||
$presale_info = model("promotion_presale")->getInfo($condition, $field);
|
||||
return $this->success($presale_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售详细信息
|
||||
* @param $presale_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleDetail($presale_id, $site_id)
|
||||
{
|
||||
//预售信息
|
||||
$alias = 'p';
|
||||
$join = [
|
||||
[
|
||||
'goods g',
|
||||
'g.goods_id = p.goods_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$presale_info = model("promotion_presale")->getInfo(
|
||||
[
|
||||
[ 'p.presale_id', '=', $presale_id ], [ 'p.site_id', '=', $site_id ],
|
||||
[ 'g.goods_state', '=', 1 ], [ 'g.is_delete', '=', 0 ]
|
||||
], 'p.*', $alias, $join
|
||||
);
|
||||
if (!empty($presale_info)) {
|
||||
//商品sku信息
|
||||
$goods_list = model('goods_sku')->getList(
|
||||
[ [ 'goods_id', '=', $presale_info[ 'goods_id' ] ] ],
|
||||
'goods_id,sku_id,sku_name,price,sku_images,stock,sku_image'
|
||||
);
|
||||
foreach ($goods_list as $k => $v) {
|
||||
$v[ 'stock' ] = numberFormat($v[ 'stock' ]);
|
||||
$presale_goods = model('promotion_presale_goods')->getInfo(
|
||||
[ [ 'presale_id', '=', $presale_id ], [ 'sku_id', '=', $v[ 'sku_id' ] ] ],
|
||||
'presale_stock,presale_deposit,presale_price'
|
||||
);
|
||||
if (empty($presale_goods)) {
|
||||
$presale_goods = [
|
||||
'presale_stock' => 0,
|
||||
'presale_deposit' => 0,
|
||||
'presale_price' => 0
|
||||
];
|
||||
}
|
||||
$goods_list[ $k ] = array_merge($v, $presale_goods);
|
||||
}
|
||||
array_multisort(array_column($goods_list, 'presale_price'), SORT_DESC, $goods_list);
|
||||
$presale_info[ 'sku_list' ] = $goods_list;
|
||||
}
|
||||
return $this->success($presale_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售详细信息
|
||||
* @param $presale_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleJoinGoodsList($presale_id, $site_id)
|
||||
{
|
||||
//预售信息
|
||||
$alias = 'p';
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = p.goods_id', 'inner' ]
|
||||
];
|
||||
$presale_info = model("promotion_presale")->getInfo(
|
||||
[
|
||||
[ 'p.presale_id', '=', $presale_id ], [ 'p.site_id', '=', $site_id ],
|
||||
[ 'g.goods_state', '=', 1 ], [ 'g.is_delete', '=', 0 ]
|
||||
], 'p.*', $alias, $join
|
||||
);
|
||||
if (!empty($presale_info)) {
|
||||
|
||||
$goods_list = model('promotion_presale_goods')->getList(
|
||||
[ [ 'ppg.presale_id', '=', $presale_info[ 'presale_id' ] ] ],
|
||||
'ppg.presale_stock,ppg.presale_deposit,ppg.presale_price,sku.sku_id,sku.sku_name,sku.price,sku.sku_image,sku.stock',
|
||||
'', 'ppg', [ [ 'goods_sku sku', 'sku.sku_id = ppg.sku_id', 'inner' ] ]
|
||||
);
|
||||
foreach ($goods_list as $k => $v) {
|
||||
$goods_list[ $k ][ 'stock' ] = numberFormat($goods_list[ $k ][ 'stock' ]);
|
||||
}
|
||||
|
||||
$presale_info[ 'sku_list' ] = $goods_list;
|
||||
}
|
||||
return $this->success($presale_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预售商品详情
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleGoodsDetail($condition = [], $field = '')
|
||||
{
|
||||
$alias = 'ppg';
|
||||
|
||||
if (empty($field)) {
|
||||
$field = 'ppg.id,ppg.presale_id,ppg.goods_id,ppg.sku_id,ppg.presale_stock,ppg.presale_stock as stock,ppg.presale_deposit,ppg.presale_price,(pp.sale_num + g.virtual_sale) as sale_num,pp.presale_name,
|
||||
pp.presale_num,pp.start_time,pp.end_time,pp.pay_start_time,pp.pay_end_time,pp.deliver_type,pp.deliver_time,sku.site_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,pp.remark,
|
||||
sku.click_num,(g.sale_num + g.virtual_sale) as goods_sale_num,sku.collect_num,sku.sku_image,sku.sku_images,sku.site_id,sku.goods_content,sku.goods_state,sku.is_virtual,
|
||||
sku.is_free_shipping,sku.goods_spec_format,sku.goods_attr_format,sku.introduction,sku.unit,sku.video_url,sku.evaluate,sku.goods_service_ids,sku.support_trade_type,
|
||||
g.goods_image,g.goods_stock,g.goods_name,sku.qr_id,g.stock_show,g.sale_show,g.label_name';
|
||||
}
|
||||
$join = [
|
||||
[ 'goods_sku sku', 'ppg.sku_id = sku.sku_id', 'inner' ],
|
||||
[ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
|
||||
[ 'promotion_presale pp', 'ppg.presale_id = pp.presale_id', 'inner' ],
|
||||
];
|
||||
$presale_goods_info = model('promotion_presale_goods')->getInfo($condition, $field, $alias, $join);
|
||||
if (!empty($presale_goods_info)) {
|
||||
if (isset($presale_goods_info[ 'goods_sale_num' ])) {
|
||||
$presale_goods_info[ 'goods_sale_num' ] = numberFormat($presale_goods_info[ 'goods_sale_num' ]);
|
||||
}
|
||||
if (isset($presale_goods_info[ 'goods_stock' ])) {
|
||||
$presale_goods_info[ 'goods_stock' ] = numberFormat($presale_goods_info[ 'goods_stock' ]);
|
||||
}
|
||||
}
|
||||
return $this->success($presale_goods_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预售商品详情
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleGoodsSkuList($condition = [])
|
||||
{
|
||||
$alias = 'ppg';
|
||||
|
||||
$field = 'ppg.id,ppg.presale_id,ppg.sku_id,ppg.presale_stock,ppg.presale_stock as stock,ppg.presale_deposit,ppg.presale_price,sku.sku_name,
|
||||
sku.sku_spec_format,sku.price,sku.sku_image,sku.sku_images,sku.goods_spec_format,g.goods_image';
|
||||
$join = [
|
||||
[ 'promotion_presale pp', 'ppg.presale_id = pp.presale_id', 'inner' ],
|
||||
[ 'goods_sku sku', 'ppg.sku_id = sku.sku_id', 'inner' ],
|
||||
[ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
|
||||
];
|
||||
$list = model('promotion_presale_goods')->getList($condition, $field, 'ppg.id asc', $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param string $limit
|
||||
*/
|
||||
public function getPresaleList($condition = [], $field = '', $order = '', $limit = null)
|
||||
{
|
||||
$alias = 'pp';
|
||||
|
||||
if (empty($field)) {
|
||||
$field = 'pp.*,g.price,g.goods_name,g.goods_image,(g.sale_num + g.virtual_sale) as goods_sale_num,g.unit,g.goods_stock,g.recommend_way';
|
||||
}
|
||||
$join = [
|
||||
[ 'goods g', 'pp.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
|
||||
$list = model('promotion_presale')->getList($condition, $field, $order, $alias, $join, '', $limit);
|
||||
foreach ($list as $k => $v) {
|
||||
if (isset($v[ 'goods_sale_num' ])) {
|
||||
$list[ $k ][ 'goods_sale_num' ] = numberFormat($list[ $k ][ 'goods_sale_num' ]);
|
||||
}
|
||||
if (isset($v[ 'goods_stock' ])) {
|
||||
$list[ $k ][ 'goods_stock' ] = numberFormat($list[ $k ][ 'goods_stock' ]);
|
||||
}
|
||||
}
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getPresalePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '')
|
||||
{
|
||||
$field = 'p.*,g.goods_name,g.goods_image,g.price';
|
||||
$alias = 'p';
|
||||
$join = [
|
||||
[
|
||||
'goods g',
|
||||
'p.goods_id = g.goods_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$list = model('promotion_presale')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售商品列表
|
||||
* @param $presale_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleGoodsList($presale_id, $site_id)
|
||||
{
|
||||
$field = 'pbg.*,sku.sku_name,sku.price,sku.sku_image,sku.stock';
|
||||
$alias = 'pbg';
|
||||
$join = [
|
||||
[
|
||||
'goods g',
|
||||
'g.goods_id = pbg.goods_id',
|
||||
'inner'
|
||||
],
|
||||
[
|
||||
'goods_sku sku',
|
||||
'sku.sku_id = pbg.sku_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$condition = [
|
||||
[ 'pbg.presale_id', '=', $presale_id ], [ 'pbg.site_id', '=', $site_id ],
|
||||
[ 'g.is_delete', '=', 0 ], [ 'g.goods_state', '=', 1 ]
|
||||
];
|
||||
|
||||
$list = model('promotion_presale_goods')->getList($condition, $field, '', $alias, $join);
|
||||
foreach ($list as $k => $v) {
|
||||
$list[ $k ][ 'stock' ] = numberFormat($list[ $k ][ 'stock' ]);
|
||||
}
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售商品分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getPresaleGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'pp.presale_id desc', $field = '')
|
||||
{
|
||||
$alias = 'pp';
|
||||
if (empty($field)) {
|
||||
$field = 'pp.*,g.price,g.goods_name,g.goods_image,(g.sale_num + g.virtual_sale) as goods_sale_num,g.unit,g.goods_stock,g.recommend_way';
|
||||
}
|
||||
$join = [
|
||||
[ 'goods g', 'pp.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
$res = model('promotion_presale')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
foreach ($res[ 'list' ] as $k => $v) {
|
||||
if (isset($v[ 'goods_sale_num' ])) {
|
||||
$res[ 'list' ][ $k ][ 'goods_sale_num' ] = numberFormat($res[ 'list' ][ $k ][ 'goods_sale_num' ]);
|
||||
}
|
||||
if (isset($v[ 'goods_stock' ])) {
|
||||
$res[ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($res[ 'list' ][ $k ][ 'goods_stock' ]);
|
||||
}
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启预售活动
|
||||
* @param $presale_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function cronOpenPresale($presale_id)
|
||||
{
|
||||
$presale_info = model('promotion_presale')->getInfo([ [ 'presale_id', '=', $presale_id ] ], 'status,goods_id');
|
||||
if (!empty($presale_info)) {
|
||||
|
||||
if ($presale_info[ 'status' ] == 0) {
|
||||
$res = model('promotion_presale')->update([ 'status' => 1, 'status_name' => $this->status[ 1 ] ], [ [ 'presale_id', '=', $presale_id ] ]);
|
||||
|
||||
$goods = new Goods();
|
||||
$goods->modifyPromotionAddon($presale_info[ 'goods_id' ], [ 'presale' => $presale_id ]);
|
||||
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error("", "预售活动已开启或者关闭");
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error("", "预售活动不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭预售活动
|
||||
* @param $presale_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function cronClosePresale($presale_id)
|
||||
{
|
||||
$presale_info = model('promotion_presale')->getInfo([ [ 'presale_id', '=', $presale_id ] ], 'status,goods_id');
|
||||
if (!empty($presale_info)) {
|
||||
|
||||
if ($presale_info[ 'status' ] == 1) {
|
||||
$res = model('promotion_presale')->update([ 'status' => 2, 'status_name' => $this->status[ 2 ] ], [ [ 'presale_id', '=', $presale_id ] ]);
|
||||
|
||||
$goods = new Goods();
|
||||
$goods->modifyPromotionAddon($presale_info[ 'goods_id' ], [ 'presale' => $presale_id ], true);
|
||||
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error("", "该活动已结束");
|
||||
}
|
||||
} else {
|
||||
return $this->error("", "预售活动不存在");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断规格值是否禁用
|
||||
* @param $presale_id
|
||||
* @param $site_id
|
||||
* @param string $goods_spec_format
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function getGoodsSpecFormat($presale_id, $site_id, $goods_spec_format = '')
|
||||
{
|
||||
//获取活动参与的商品sku_ids
|
||||
$sku_ids = model('promotion_presale_goods')->getColumn([ [ 'presale_id', '=', $presale_id ], [ 'site_id', '=', $site_id ] ], 'sku_id');
|
||||
$goods_model = new Goods();
|
||||
$res = $goods_model->getGoodsSpecFormat($sku_ids, $goods_spec_format);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断sku是否参与预售
|
||||
* @param $sku_id
|
||||
* @return array
|
||||
*/
|
||||
public function isJoinPresaleBySkuId($sku_id)
|
||||
{
|
||||
$condition = [
|
||||
[ 'ppg.sku_id', '=', $sku_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'pp.end_time', '>=', time() ]
|
||||
];
|
||||
$alias = 'ppg';
|
||||
$join = [
|
||||
[ 'promotion_presale pp', 'pp.presale_id = ppg.presale_id', 'inner' ]
|
||||
];
|
||||
$info = model('promotion_presale_goods')->getInfo($condition, 'ppg.presale_id,ppg.sku_id', $alias, $join);
|
||||
if (empty($info)) {
|
||||
return $this->error();
|
||||
} else {
|
||||
return $this->success([ 'promotion_type' => 'presale', 'presale_id' => $info[ 'presale_id' ], 'sku_id' => $sku_id ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断sku是否参与预售
|
||||
* @param $sku_ids
|
||||
* @return array
|
||||
*/
|
||||
public function isJoinPresaleBySkuIds($sku_ids)
|
||||
{
|
||||
$condition = [
|
||||
[ 'ppg.sku_id', 'in', $sku_ids ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'pp.end_time', '>=', time() ]
|
||||
];
|
||||
$alias = 'ppg';
|
||||
$join = [
|
||||
[ 'promotion_presale pp', 'pp.presale_id = ppg.presale_id', 'inner' ]
|
||||
];
|
||||
$list = model('promotion_presale_goods')->getList($condition, 'ppg.presale_id,ppg.sku_id', '', $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断sku是否参与预售
|
||||
* @param $sku_id
|
||||
* @return array
|
||||
*/
|
||||
public function isJoinPresaleByGoodsId($goods_id)
|
||||
{
|
||||
$condition = [
|
||||
[ 'ppg.goods_id', '=', $goods_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'pp.end_time', '>=', time() ]
|
||||
];
|
||||
$alias = 'ppg';
|
||||
$join = [
|
||||
[ 'promotion_presale pp', 'pp.presale_id = ppg.presale_id', 'inner' ]
|
||||
];
|
||||
$list = model('promotion_presale_goods')->getList($condition, 'ppg.presale_id,ppg.sku_id','', $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员已购该商品数
|
||||
* @param $goods_id
|
||||
* @param $member_id
|
||||
* @return float
|
||||
*/
|
||||
public function getGoodsPurchasedNum($presale_id, $member_id)
|
||||
{
|
||||
$num = model("promotion_presale_order")->getSum([
|
||||
[ 'member_id', '=', $member_id ],
|
||||
[ 'presale_id', '=', $presale_id ],
|
||||
[ 'order_status', '<>', PresaleOrderCommon::ORDER_CLOSE ],
|
||||
[ 'refund_status', '<>', PresaleOrderRefund::REFUND_COMPLETE ]
|
||||
], 'num');
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售订单数量
|
||||
* @param $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleOrderCount($condition, $field = '*')
|
||||
{
|
||||
$count = model("promotion_presale_order")->getCount($condition, $field);
|
||||
return $this->success($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询预售商品数量
|
||||
* @param array $where
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param null $join
|
||||
* @param null $group
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleGoodsCount($where = [], $field = '*', $alias = 'a', $join = null, $group = null)
|
||||
{
|
||||
$count = model("promotion_presale_order")->getCount($where, $field, $alias, $join, $group);
|
||||
return $this->success($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成预售二维码
|
||||
* @param $presale_id
|
||||
* @param string $name
|
||||
* @param string $type 类型 create创建 get获取
|
||||
* @return mixed|array
|
||||
*/
|
||||
public function qrcode($presale_id, $name, $site_id, $type = 'create')
|
||||
{
|
||||
$data = [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => "all", // all为全部
|
||||
'type' => $type, // 类型 create创建 get获取
|
||||
'data' => [
|
||||
'id' => $presale_id
|
||||
],
|
||||
'page' => '/pages_promotion/presale/detail',
|
||||
'qrcode_path' => 'upload/qrcode/presale',
|
||||
'qrcode_name' => "presale_qrcode_" . $presale_id
|
||||
];
|
||||
|
||||
event('Qrcode', $data, true);
|
||||
$app_type_list = config('app_type');
|
||||
$path = [];
|
||||
foreach ($app_type_list as $k => $v) {
|
||||
switch ( $k ) {
|
||||
case 'h5':
|
||||
$wap_domain = getH5Domain();
|
||||
$path[ $k ][ 'status' ] = 1;
|
||||
$path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ] . '?id=' . $presale_id;
|
||||
$path[ $k ][ 'img' ] = "upload/qrcode/presale/presale_qrcode_" . $presale_id . "_" . $k . ".png";
|
||||
break;
|
||||
case 'weapp' :
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
|
||||
if (!empty($res[ 'data' ])) {
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信小程序';
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 1;
|
||||
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
|
||||
}
|
||||
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信小程序';
|
||||
}
|
||||
break;
|
||||
case 'wechat' :
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
|
||||
if (!empty($res[ 'data' ])) {
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信公众号';
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 1;
|
||||
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
|
||||
}
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信公众号';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$return = [
|
||||
'path' => $path,
|
||||
'name' => $name,
|
||||
];
|
||||
|
||||
return $this->success($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品用到的分类
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsCategoryIds($condition)
|
||||
{
|
||||
$cache_name = "shop_presale_goods_category_" . md5(json_encode($condition));
|
||||
$cache_time = 60;
|
||||
$cache_res = Cache::get($cache_name);
|
||||
if (empty($cache_res) || time() - $cache_res[ 'time' ] > $cache_time) {
|
||||
$list = Db::name('promotion_presale')
|
||||
->alias('pp')
|
||||
->join('goods g', 'pp.goods_id = g.goods_id', 'inner')
|
||||
->where($condition)
|
||||
->group('g.category_id')
|
||||
->column('g.category_id');
|
||||
$category_ids = trim(join('0', $list), ',');
|
||||
$category_id_arr = array_unique(explode(',', $category_ids));
|
||||
Cache::set($cache_name, [ 'time' => time(), 'data' => $category_id_arr ]);
|
||||
} else {
|
||||
$category_id_arr = $cache_res[ 'data' ];
|
||||
}
|
||||
return $this->success($category_id_arr);
|
||||
}
|
||||
|
||||
public function urlQrcode($page, $qrcode_param, $promotion_type, $app_type, $site_id)
|
||||
{
|
||||
$params = [
|
||||
'site_id' => $site_id,
|
||||
'data' => $qrcode_param,
|
||||
'page' => $page,
|
||||
'promotion_type' => $promotion_type,
|
||||
'app_type' => $app_type,
|
||||
'h5_path' => $page . '?id=' . $qrcode_param[ 'id' ],
|
||||
'qrcode_path' => 'upload/qrcode/presale',
|
||||
'qrcode_name' => 'presale_qrcode_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $site_id
|
||||
];
|
||||
$solitaire = event('PromotionQrcode', $params, true);
|
||||
return $this->success($solitaire);
|
||||
}
|
||||
}
|
||||
52
addon/presale/model/PresaleOrder.php
Executable file
52
addon/presale/model/PresaleOrder.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 商品预售
|
||||
*/
|
||||
class PresaleOrder extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取预售订单信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleOrderInfo($condition = [], $field = '*')
|
||||
{
|
||||
$info = model('promotion_presale_order')->getInfo($condition, $field);
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售订单分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleOrderPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'id desc', $field = '*')
|
||||
{
|
||||
$join = [
|
||||
[ 'member m', 'ppo.member_id = m.member_id', 'left' ]
|
||||
];
|
||||
$field = 'ppo.*,m.nickname';
|
||||
$list = model('promotion_presale_order')->pageList($condition, $field, $order, $page, $page_size, 'ppo', $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
780
addon/presale/model/PresaleOrderCommon.php
Executable file
780
addon/presale/model/PresaleOrderCommon.php
Executable file
@@ -0,0 +1,780 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model;
|
||||
|
||||
use addon\coupon\model\Coupon;
|
||||
use addon\store\model\StoreGoodsSku;
|
||||
use app\dict\member_account\AccountDict;
|
||||
use app\model\BaseModel;
|
||||
use app\model\member\MemberAccount;
|
||||
use app\model\order\Config;
|
||||
use app\model\order\Order;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderLog;
|
||||
use app\model\system\Cron;
|
||||
use app\model\system\Pay;
|
||||
|
||||
/**
|
||||
* 商品预售
|
||||
*/
|
||||
class PresaleOrderCommon extends BaseModel
|
||||
{
|
||||
// 订单待付款
|
||||
const ORDER_CREATE = 0;
|
||||
//等待付尾款
|
||||
const WAIT_FINAL_PAY = 1;
|
||||
//订单完成(尾款已支付)
|
||||
const ORDER_PAY = 2;
|
||||
// 订单已关闭
|
||||
const ORDER_CLOSE = -1;
|
||||
|
||||
/**
|
||||
* 基础订单状态(不同类型的订单可以不使用这些状态,但是不能冲突)
|
||||
* @var unknown
|
||||
*/
|
||||
public $order_status = [
|
||||
|
||||
self::ORDER_CREATE => [
|
||||
'status' => self::ORDER_CREATE,
|
||||
'name' => '待付款',
|
||||
'is_allow_refund' => 0,
|
||||
'icon' => 'public/uniapp/order/order-icon-send.png',
|
||||
'action' => [
|
||||
[
|
||||
'action' => 'orderClose',
|
||||
'title' => '关闭订单',
|
||||
'color' => ''
|
||||
],
|
||||
[
|
||||
'action' => 'offlinePayDeposit',
|
||||
'title' => '线下支付定金',
|
||||
'color' => ''
|
||||
],
|
||||
],
|
||||
'member_action' => [
|
||||
[
|
||||
'action' => 'orderClose',
|
||||
'title' => '关闭订单',
|
||||
'color' => ''
|
||||
],
|
||||
[
|
||||
'action' => 'orderPayDeposit',
|
||||
'title' => '支付定金',
|
||||
'color' => ''
|
||||
],
|
||||
],
|
||||
'color' => ''
|
||||
],
|
||||
self::WAIT_FINAL_PAY => [
|
||||
'status' => self::WAIT_FINAL_PAY,
|
||||
'name' => '待付尾款',
|
||||
'is_allow_refund' => 0,
|
||||
'icon' => 'public/uniapp/order/order-icon-send.png',
|
||||
'action' => [
|
||||
[
|
||||
'action' => 'offlinePayFinal',
|
||||
'title' => '线下支付尾款',
|
||||
'color' => ''
|
||||
],
|
||||
],
|
||||
'member_action' => [
|
||||
[
|
||||
'action' => 'refundDeposit',
|
||||
'title' => '退定金',
|
||||
'color' => ''
|
||||
],
|
||||
[
|
||||
'action' => 'orderPayFinal',
|
||||
'title' => '支付尾款',
|
||||
'color' => ''
|
||||
],
|
||||
],
|
||||
'color' => ''
|
||||
],
|
||||
self::ORDER_PAY => [
|
||||
'status' => self::ORDER_PAY,
|
||||
'name' => '已完成',
|
||||
'is_allow_refund' => 0,
|
||||
'icon' => 'public/uniapp/order/order-icon-send.png',
|
||||
'action' => [],
|
||||
'member_action' => [],
|
||||
'color' => ''
|
||||
],
|
||||
self::ORDER_CLOSE => [
|
||||
'status' => self::ORDER_CLOSE,
|
||||
'name' => '已关闭',
|
||||
'is_allow_refund' => 0,
|
||||
'icon' => 'public/uniapp/order/order-icon-close.png',
|
||||
'action' => [
|
||||
[
|
||||
'action' => 'deleteOrder',
|
||||
'title' => '删除订单',
|
||||
'color' => ''
|
||||
],
|
||||
],
|
||||
'member_action' => [
|
||||
[
|
||||
'action' => 'deleteOrder',
|
||||
'title' => '删除订单',
|
||||
'color' => ''
|
||||
],
|
||||
],
|
||||
'color' => ''
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
* @return array
|
||||
*/
|
||||
public function getOrderStatus()
|
||||
{
|
||||
return $this->success($this->order_status);
|
||||
}
|
||||
|
||||
/*********************************************** 订单关闭 start *****************************************************************/
|
||||
|
||||
/**
|
||||
* 订单关闭
|
||||
* @param array $condition
|
||||
*/
|
||||
public function depositOrderClose($condition = [])
|
||||
{
|
||||
$info = model('promotion_presale_order')->getInfo($condition, 'id,order_status');
|
||||
if (empty($info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
if ($info[ 'order_status' ] == self::ORDER_CLOSE) {
|
||||
return $this->error('', '该订单已关闭');
|
||||
}
|
||||
if ($info[ 'order_status' ] != self::ORDER_CREATE) {
|
||||
return $this->error('', '该订单已支付或已完成');
|
||||
}
|
||||
|
||||
$res = $this->cronDepositOrderClose($info[ 'id' ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加定金订单自动关闭
|
||||
*/
|
||||
public function addDepositOrderCronClose($order_id, $site_id)
|
||||
{
|
||||
//计算订单自动关闭时间
|
||||
$config_model = new Config();
|
||||
$order_config_result = $config_model->getOrderEventTimeConfig($site_id);
|
||||
$order_config = $order_config_result[ "data" ];
|
||||
$now_time = time();
|
||||
if (!empty($order_config)) {
|
||||
$execute_time = $now_time + $order_config[ "value" ][ "auto_close" ] * 60; //自动关闭时间
|
||||
} else {
|
||||
$execute_time = $now_time + 3600; //尚未配置 默认一天
|
||||
}
|
||||
$cron_model = new Cron();
|
||||
$cron_model->addCron(1, 0, "预售订单自动关闭", "CronDepositOrderClose", $execute_time, $order_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加尾款支付到期自动退定金操作
|
||||
*/
|
||||
public function addRefundOrderCronClose($order_id, $site_id, $time)
|
||||
{
|
||||
//计算订单自动关闭时间
|
||||
// $config_model = new Config();
|
||||
// $order_config_result = $config_model->getOrderEventTimeConfig($site_id);
|
||||
// $order_config = $order_config_result["data"];
|
||||
// $now_time = time();
|
||||
// if (!empty($order_config)) {
|
||||
// $execute_time = $now_time + $order_config["value"]["auto_close"] * 60; //自动关闭时间
|
||||
// } else {
|
||||
// $execute_time = $now_time + 3600; //尚未配置 默认一天
|
||||
// }
|
||||
$cron_model = new Cron();
|
||||
$cron_model->addCron(1, 0, "预售订单尾款支付到期退定金", "CronRefundOrderDepositClose", $time, $order_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动关闭定金订单
|
||||
* @param $order_id
|
||||
* @return array
|
||||
*/
|
||||
public function cronDepositOrderClose($order_id)
|
||||
{
|
||||
$order_info = model('promotion_presale_order')->getInfo([ [ 'id', '=', $order_id ] ]);
|
||||
if (empty($order_info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
//订单已关闭
|
||||
if ($order_info[ 'order_status' ] == self::ORDER_CLOSE) {
|
||||
return $this->success();
|
||||
}
|
||||
if ($order_info[ 'order_status' ] != self::ORDER_CREATE) {
|
||||
return $this->success();
|
||||
}
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
//修改订单状态
|
||||
$data = [
|
||||
'order_status' => self::ORDER_CLOSE,
|
||||
'order_status_name' => $this->order_status[ self::ORDER_CLOSE ][ "name" ],
|
||||
'order_status_action' => json_encode($this->order_status[ self::ORDER_CLOSE ], JSON_UNESCAPED_UNICODE),
|
||||
'close_time' => time(),
|
||||
];
|
||||
model('promotion_presale_order')->update($data, [ [ 'id', '=', $order_id ] ]);
|
||||
|
||||
//增加库存
|
||||
// model('promotion_presale')->setInc([['presale_id','=',$order_info['presale_id']]],'presale_stock',$order_info['num']);
|
||||
//返还sku库存 2021.06.10
|
||||
model('promotion_presale_goods')->setInc([ [ 'presale_id', '=', $order_info[ 'presale_id' ] ], [ 'sku_id', '=', $order_info[ 'sku_id' ] ] ], 'presale_stock', $order_info[ 'num' ]);
|
||||
//增加门店库存
|
||||
if ($order_info[ 'delivery_store_id' ] > 0) {
|
||||
|
||||
$store_data = [
|
||||
'delivery_store_id' => $order_info[ 'delivery_store_id' ],
|
||||
'num' => $order_info[ 'num' ],
|
||||
'sku_id' => $order_info[ 'sku_id' ]
|
||||
];
|
||||
$store_result = $this->incStoreGoodsStock($store_data);
|
||||
if ($store_result[ 'code' ] < 0) {
|
||||
return $store_result;
|
||||
}
|
||||
}
|
||||
|
||||
//返还店铺优惠券
|
||||
$coupon_id = $order_info[ "coupon_id" ];
|
||||
if ($coupon_id > 0) {
|
||||
$coupon_model = new Coupon();
|
||||
$coupon_model->refundCoupon($coupon_id, $order_info[ "member_id" ]);
|
||||
}
|
||||
//平台优惠券
|
||||
|
||||
//平台余额 退还余额
|
||||
if ($order_info[ "balance_deposit_money" ] > 0) {
|
||||
$member_account_model = new MemberAccount();
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ "member_id" ], AccountDict::balance, $order_info[ "balance_deposit_money" ], "presale_deposit_refund", "余额返还", "订单关闭返还");
|
||||
}
|
||||
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单尾款结束自动退款
|
||||
* @param $order_id
|
||||
* @return array
|
||||
*/
|
||||
public function cronRefundOrderDepositClose($order_id)
|
||||
{
|
||||
$order_info = model('promotion_presale_order')->getInfo([ [ 'id', '=', $order_id ] ]);
|
||||
if (empty($order_info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
//订单已关闭
|
||||
if ($order_info[ 'order_status' ] == self::ORDER_CLOSE) {
|
||||
return $this->success();
|
||||
}
|
||||
if ($order_info[ 'order_status' ] != self::WAIT_FINAL_PAY) {
|
||||
return $this->success();
|
||||
}
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
//修改订单状态
|
||||
$data = [
|
||||
'order_status' => self::ORDER_CLOSE,
|
||||
'order_status_name' => $this->order_status[ self::ORDER_CLOSE ][ "name" ],
|
||||
'order_status_action' => json_encode($this->order_status[ self::ORDER_CLOSE ], JSON_UNESCAPED_UNICODE),
|
||||
'close_time' => time(),
|
||||
];
|
||||
model('promotion_presale_order')->update($data, [ [ 'id', '=', $order_id ] ]);
|
||||
|
||||
//增加库存
|
||||
// model('promotion_presale')->setInc([['presale_id','=',$order_info['presale_id']]],'presale_stock',$order_info['num']);
|
||||
//返还sku库存 2021.06.10
|
||||
model('promotion_presale_goods')->setInc([ [ 'presale_id', '=', $order_info[ 'presale_id' ] ], [ 'sku_id', '=', $order_info[ 'sku_id' ] ] ], 'presale_stock', $order_info[ 'num' ]);
|
||||
//增加门店库存
|
||||
if ($order_info[ 'delivery_store_id' ] > 0) {
|
||||
|
||||
$store_data = [
|
||||
'delivery_store_id' => $order_info[ 'delivery_store_id' ],
|
||||
'num' => $order_info[ 'num' ],
|
||||
'sku_id' => $order_info[ 'sku_id' ]
|
||||
];
|
||||
$store_result = $this->incStoreGoodsStock($store_data);
|
||||
if ($store_result[ 'code' ] < 0) {
|
||||
return $store_result;
|
||||
}
|
||||
}
|
||||
|
||||
//返还店铺优惠券
|
||||
$coupon_id = $order_info[ "coupon_id" ];
|
||||
if ($coupon_id > 0) {
|
||||
$coupon_model = new Coupon();
|
||||
$coupon_model->refundCoupon($coupon_id, $order_info[ "member_id" ]);
|
||||
}
|
||||
//平台优惠券
|
||||
|
||||
//平台余额 退还余额
|
||||
if ($order_info[ "balance_deposit_money" ] > 0) {
|
||||
$member_account_model = new MemberAccount();
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ "member_id" ], AccountDict::balance, $order_info[ "balance_deposit_money" ], "presale_deposit_refund", "余额返还", "订单关闭返还");
|
||||
}
|
||||
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单关闭增加门店商品库存
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function incStoreGoodsStock($data)
|
||||
{
|
||||
$store_goods_sku_model = new StoreGoodsSku();
|
||||
$stock_result = $store_goods_sku_model->incStock([ "store_id" => $data[ "delivery_store_id" ], "sku_id" => $data[ "sku_id" ], "stock" => $data[ "num" ] ]);
|
||||
if ($stock_result[ "code" ] < 0) {
|
||||
return $stock_result;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************** 订单关闭 end ******************************************************/
|
||||
|
||||
/********************************************** 订单线下支付 start *************************************************/
|
||||
|
||||
/**
|
||||
* 线下支付定金
|
||||
* @param $order_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function offlinePayDeposit($order_id, $site_id)
|
||||
{
|
||||
$order_info = model("promotion_presale_order")->getInfo(
|
||||
[ [ 'id', '=', $order_id ], [ 'site_id', '=', $site_id ] ],
|
||||
'deposit_out_trade_no,order_status'
|
||||
);
|
||||
if (empty($order_info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
if ($order_info[ 'order_status' ] != self::ORDER_CREATE) {
|
||||
return $this->error('', '订单已经支付或已经关闭');
|
||||
}
|
||||
|
||||
$pay_model = new Pay();
|
||||
$result = $pay_model->onlinePay($order_info[ 'deposit_out_trade_no' ], "offlinepay", '', '');
|
||||
if ($result[ "code" ] < 0) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付尾款
|
||||
* @param $order_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function offlinePayFinal($order_id, $site_id)
|
||||
{
|
||||
$order_info = model("promotion_presale_order")->getInfo(
|
||||
[ [ 'id', '=', $order_id ], [ 'site_id', '=', $site_id ] ],
|
||||
'final_out_trade_no,order_status,pay_start_time,pay_end_time'
|
||||
);
|
||||
if (empty($order_info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
if ($order_info[ 'order_status' ] != self::WAIT_FINAL_PAY) {
|
||||
return $this->error('', '订单已经支付或已经关闭');
|
||||
}
|
||||
|
||||
// if ($order_info['pay_start_time'] > time() || $order_info['pay_end_time'] < time()){
|
||||
// return $this->error('','未在尾款支付时间');
|
||||
// }
|
||||
|
||||
if (!( $order_info[ 'pay_start_time' ] < time() && time() < $order_info[ 'pay_end_time' ] )) {
|
||||
return $this->error('', '未在尾款支付时间');
|
||||
}
|
||||
|
||||
if (empty($order_info[ 'final_out_trade_no' ])) {
|
||||
|
||||
$pay = new Pay();
|
||||
$out_trade_no = $pay->createOutTradeNo();
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
|
||||
model('promotion_presale_order')->update(
|
||||
[ 'final_out_trade_no' => $out_trade_no ],
|
||||
[ [ 'id', '=', $order_id ], [ 'site_id', '=', $site_id ] ]
|
||||
);
|
||||
|
||||
//将预售订单信息添加到普通订单中
|
||||
$res = $this->finalOrderOnlinePay([ 'out_trade_no' => $out_trade_no, 'pay_type' => 'offlinepay' ]);
|
||||
if ($res[ 'code' ] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $res;
|
||||
}
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
$pay_model = new Pay();
|
||||
$result = $pay_model->onlinePay($order_info[ 'final_out_trade_no' ], "offlinepay", '', '');
|
||||
if ($result[ "code" ] < 0) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** 订单线下支付 end ***************************************************/
|
||||
|
||||
/*********************************************** 订单异步回调 start ************************************************/
|
||||
|
||||
/**
|
||||
* 定金订单线上支付回调
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function depositOrderOnlinePay($data)
|
||||
{
|
||||
$out_trade_no = $data[ "out_trade_no" ];
|
||||
$order_info = model("promotion_presale_order")->getInfo([ [ 'deposit_out_trade_no', '=', $out_trade_no ] ]);
|
||||
if ($order_info[ 'order_status' ] != self::ORDER_CREATE) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
$order_model = new Order();
|
||||
$pay_type_list = $order_model->getPayType();
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
|
||||
//获取预售活动信息
|
||||
$presale_info = model('promotion_presale')->getInfo([ [ 'presale_id', '=', $order_info[ 'presale_id' ] ] ], 'deliver_type,deliver_time');
|
||||
if ($presale_info[ 'deliver_type' ] == 0) {
|
||||
$predict_delivery_time = $presale_info[ 'deliver_time' ];
|
||||
} else {
|
||||
$predict_delivery_time = strtotime('+' . $presale_info[ 'deliver_time' ] . 'days');
|
||||
}
|
||||
|
||||
//修改订单状态
|
||||
$order_data = [
|
||||
'order_status' => self::WAIT_FINAL_PAY,
|
||||
'order_status_name' => $this->order_status[ self::WAIT_FINAL_PAY ][ "name" ],
|
||||
'order_status_action' => json_encode($this->order_status[ self::WAIT_FINAL_PAY ], JSON_UNESCAPED_UNICODE),
|
||||
'pay_deposit_time' => time(),
|
||||
'deposit_pay_type' => $data[ 'pay_type' ],
|
||||
'deposit_pay_type_name' => $pay_type_list[ $data[ 'pay_type' ] ],
|
||||
'predict_delivery_time' => $predict_delivery_time
|
||||
];
|
||||
model("promotion_presale_order")->update($order_data, [ [ 'id', '=', $order_info[ 'id' ] ] ]);
|
||||
|
||||
if ($order_info[ 'final_money' ] == 0) {
|
||||
// $this->finalOrderOnlinePay(['out_trade_no' => $order_info['final_out_trade_no'], 'id' => $order_info['id'], 'pay_type' => $data['pay_type'] ]);
|
||||
}
|
||||
//增加销量
|
||||
model('promotion_presale')->setInc([ [ 'presale_id', '=', $order_info[ 'presale_id' ] ] ], 'sale_num', $order_info[ 'num' ]);
|
||||
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尾款订单线上支付回调
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function finalOrderOnlinePay($data)
|
||||
{
|
||||
if ($data[ "out_trade_no" ] == '' && isset($data[ 'id' ])) {
|
||||
$condition = [ [ 'id', '=', $data[ 'id' ] ] ];
|
||||
} else {
|
||||
$condition = [ [ 'final_out_trade_no', '=', $data[ "out_trade_no" ] ] ];
|
||||
}
|
||||
|
||||
$order_info = model("promotion_presale_order")->getInfo($condition);
|
||||
if ($order_info[ 'order_status' ] != self::WAIT_FINAL_PAY) {
|
||||
return $this->success();
|
||||
}
|
||||
$order_model = new Order();
|
||||
$pay_type_list = $order_model->getPayType();
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
|
||||
//修改预售订单状态
|
||||
$order_data = [
|
||||
'order_status' => self::ORDER_PAY,
|
||||
'order_status_name' => $this->order_status[ self::ORDER_PAY ][ "name" ],
|
||||
'order_status_action' => json_encode($this->order_status[ self::ORDER_PAY ], JSON_UNESCAPED_UNICODE),
|
||||
'pay_final_time' => time(),
|
||||
'final_pay_type' => $data[ 'pay_type' ],
|
||||
'final_pay_type_name' => $pay_type_list[ $data[ 'pay_type' ] ]
|
||||
];
|
||||
model("promotion_presale_order")->update($order_data, [ [ 'id', '=', $order_info[ 'id' ] ] ]);
|
||||
|
||||
//将预售订单信息添加到普通订单中
|
||||
$res = $this->presaleOrderToOrder($order_info);
|
||||
if ($res[ 'code' ] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $res;
|
||||
}
|
||||
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将预售订单信息添加到普通订单中
|
||||
* @param $presale_order
|
||||
* @return array
|
||||
*/
|
||||
public function presaleOrderToOrder($presale_order)
|
||||
{
|
||||
model('order')->startTrans();
|
||||
model("order_log")->startTrans();
|
||||
try {
|
||||
//添加订单记录
|
||||
$order_data = [
|
||||
'order_no' => $presale_order[ 'order_no' ],
|
||||
'site_id' => $presale_order[ 'site_id' ],
|
||||
'site_name' => $presale_order[ 'site_name' ],
|
||||
'order_name' => $presale_order[ 'sku_name' ],
|
||||
'order_from' => $presale_order[ 'order_from' ],
|
||||
'order_from_name' => $presale_order[ 'order_from_name' ],
|
||||
'order_type' => $presale_order[ 'order_type' ],
|
||||
'order_type_name' => $presale_order[ 'order_type_name' ],
|
||||
'out_trade_no' => $presale_order[ 'deposit_out_trade_no' ],
|
||||
'out_trade_no_2' => $presale_order[ 'final_out_trade_no' ],
|
||||
'pay_type' => $presale_order[ 'deposit_pay_type' ],
|
||||
'pay_type_name' => $presale_order[ 'deposit_pay_type_name' ],
|
||||
'delivery_type' => $presale_order[ 'delivery_type' ],
|
||||
'delivery_type_name' => $presale_order[ 'delivery_type_name' ],
|
||||
'member_id' => $presale_order[ 'member_id' ],
|
||||
'name' => $presale_order[ 'name' ],
|
||||
'mobile' => $presale_order[ 'mobile' ],
|
||||
'telephone' => $presale_order[ 'telephone' ],
|
||||
'province_id' => $presale_order[ 'province_id' ],
|
||||
'city_id' => $presale_order[ 'city_id' ],
|
||||
'district_id' => $presale_order[ 'district_id' ],
|
||||
'community_id' => $presale_order[ 'community_id' ],
|
||||
'address' => $presale_order[ 'address' ],
|
||||
'full_address' => $presale_order[ 'full_address' ],
|
||||
'longitude' => $presale_order[ 'longitude' ],
|
||||
'latitude' => $presale_order[ 'latitude' ],
|
||||
'buyer_ip' => $presale_order[ 'buyer_ip' ],
|
||||
'buyer_ask_delivery_time' => $presale_order[ 'buyer_ask_delivery_time' ],
|
||||
'delivery_start_time' => $presale_order[ 'delivery_start_time' ],
|
||||
'delivery_end_time' => $presale_order[ 'delivery_end_time' ],
|
||||
|
||||
'buyer_message' => $presale_order[ 'buyer_message' ],
|
||||
'goods_money' => $presale_order[ 'goods_money' ],
|
||||
'delivery_money' => $presale_order[ 'delivery_money' ],
|
||||
'promotion_money' => $presale_order[ 'promotion_money' ],
|
||||
'coupon_id' => $presale_order[ 'coupon_id' ],
|
||||
'coupon_money' => $presale_order[ 'coupon_money' ],
|
||||
'invoice_money' => $presale_order[ 'invoice_money' ],
|
||||
'order_money' => $presale_order[ 'order_money' ],
|
||||
'balance_money' => $presale_order[ 'balance_deposit_money' ] + $presale_order[ 'balance_final_money' ],
|
||||
'pay_money' => $presale_order[ 'pay_deposit_money' ] + $presale_order[ 'pay_final_money' ],//现金支付金额
|
||||
'create_time' => $presale_order[ 'create_time' ],
|
||||
'pay_time' => time(),
|
||||
'goods_num' => $presale_order[ 'num' ],
|
||||
'delivery_store_id' => $presale_order[ 'delivery_store_id' ],
|
||||
'delivery_store_name' => $presale_order[ 'delivery_store_name' ],
|
||||
'delivery_store_info' => $presale_order[ 'delivery_store_info' ],
|
||||
'promotion_type' => 'presale',
|
||||
'promotion_type_name' => '商品预售',
|
||||
'promotion_status_name' => '已完成',
|
||||
'is_invoice' => $presale_order[ 'is_invoice' ],
|
||||
'invoice_type' => $presale_order[ 'invoice_type' ],
|
||||
'invoice_title' => $presale_order[ 'invoice_title' ],
|
||||
'taxpayer_number' => $presale_order[ 'taxpayer_number' ],
|
||||
'invoice_rate' => $presale_order[ 'invoice_rate' ],
|
||||
'invoice_content' => $presale_order[ 'invoice_content' ],
|
||||
'invoice_delivery_money' => $presale_order[ 'invoice_delivery_money' ],
|
||||
'invoice_full_address' => $presale_order[ 'invoice_full_address' ],
|
||||
'is_tax_invoice' => $presale_order[ 'is_tax_invoice' ],
|
||||
'invoice_email' => $presale_order[ 'invoice_email' ],
|
||||
'invoice_title_type' => $presale_order[ 'invoice_title_type' ],
|
||||
'is_fenxiao' => $presale_order[ 'is_fenxiao' ],
|
||||
'predict_delivery_time' => $presale_order[ 'predict_delivery_time' ],//预计发货时间
|
||||
'store_id' => $presale_order[ 'delivery_store_id' ]
|
||||
];
|
||||
$order_id = model('order')->add($order_data);
|
||||
|
||||
$sku_info = model('goods_sku')->getInfo([
|
||||
[ 'site_id', '=', $presale_order[ 'site_id' ] ],
|
||||
[ 'sku_id', '=', $presale_order[ 'sku_id' ] ]
|
||||
], 'supplier_id');
|
||||
|
||||
//添加订单商品项
|
||||
$order_goods_data = [
|
||||
'order_id' => $order_id,
|
||||
'order_no' => $presale_order[ 'order_no' ],
|
||||
'site_id' => $presale_order[ 'site_id' ],
|
||||
'member_id' => $presale_order[ 'member_id' ],
|
||||
'goods_id' => $presale_order[ 'goods_id' ],
|
||||
'sku_id' => $presale_order[ 'sku_id' ],
|
||||
'sku_name' => $presale_order[ 'sku_name' ],
|
||||
'sku_image' => $presale_order[ 'sku_image' ],
|
||||
'sku_no' => $presale_order[ 'sku_no' ],
|
||||
'is_virtual' => $presale_order[ 'is_virtual' ],
|
||||
'goods_class' => $presale_order[ 'goods_class' ],
|
||||
'goods_class_name' => $presale_order[ 'goods_class_name' ],
|
||||
'price' => $presale_order[ 'price' ],
|
||||
'cost_price' => $presale_order[ 'cost_price' ],
|
||||
'num' => $presale_order[ 'num' ],
|
||||
'goods_money' => $presale_order[ 'goods_money' ],
|
||||
'cost_money' => $presale_order[ 'cost_price' ] * $presale_order[ 'num' ],
|
||||
'real_goods_money' => $presale_order[ 'goods_money' ] - ( $presale_order[ 'presale_money' ] - $presale_order[ 'presale_deposit_money' ] ),
|
||||
'promotion_money' => $presale_order[ 'promotion_money' ],
|
||||
'coupon_money' => $presale_order[ 'coupon_money' ],
|
||||
'goods_name' => $presale_order[ 'goods_name' ],
|
||||
'sku_spec_format' => $presale_order[ 'sku_spec_format' ],
|
||||
'is_fenxiao' => $presale_order[ 'is_fenxiao' ],
|
||||
'delivery_status_name' => '未发货',
|
||||
'delivery_status' => 0,
|
||||
'create_time' => time(),
|
||||
'store_id' => $presale_order[ 'delivery_store_id' ],
|
||||
'supplier_id' => $sku_info[ 'supplier_id' ] ?? 0
|
||||
];
|
||||
model('order_goods')->add($order_goods_data);
|
||||
model('promotion_presale_order')->update([ 'relate_order_id' => $order_id ], [ [ 'id', '=', $presale_order[ 'id' ] ] ]);
|
||||
//调用线上支付
|
||||
$order_model = new OrderCommon();
|
||||
|
||||
//记录订单日志 start
|
||||
//获取用户信息
|
||||
$member_info = model('member')->getInfo([ 'member_id' => $presale_order[ 'member_id' ] ], 'nickname');
|
||||
$buyer_name = empty($member_info[ 'nickname' ]) ? '' : '【' . $member_info[ 'nickname' ] . '】';
|
||||
$log_data = [
|
||||
'order_id' => $order_id,
|
||||
'action' => '买家' . $buyer_name . '下单了',
|
||||
'uid' => $presale_order[ 'member_id' ],
|
||||
'nick_name' => $member_info[ 'nickname' ],
|
||||
'action_way' => 1,
|
||||
'order_status' => 0,
|
||||
'order_status_name' => '待支付'
|
||||
];
|
||||
OrderLog::addOrderLog($log_data, $order_model);
|
||||
//记录订单日志 end
|
||||
|
||||
$result = $order_model->orderOnlinePay([ 'out_trade_no' => $presale_order[ 'deposit_out_trade_no' ], 'pay_type' => $presale_order[ 'deposit_pay_type' ] ]);
|
||||
if ($result[ 'code' ] < 0) {
|
||||
model('order')->rollback();
|
||||
return $result;
|
||||
}
|
||||
model('order')->commit();
|
||||
model("order_log")->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('order')->rollback();
|
||||
model("order_log")->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*********************************************** 订单异步回调 end *****************************************************************/
|
||||
|
||||
/**
|
||||
* 订单删除
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function deleteOrder($condition)
|
||||
{
|
||||
$info = model('promotion_presale_order')->getInfo($condition, 'order_status');
|
||||
if (empty($info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
if ($info[ 'order_status' ] != self::ORDER_CLOSE) {
|
||||
return $this->error('', '抱歉,只有已关闭的订单才可以删除');
|
||||
}
|
||||
|
||||
$res = model('promotion_presale_order')->delete($condition);
|
||||
if ($res) {
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定金/尾款支付流水号
|
||||
* @param $id
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleOrderOutTradeNo($id, $member_id, $site_id)
|
||||
{
|
||||
//订单信息
|
||||
$order_info = model('promotion_presale_order')->getInfo(
|
||||
[
|
||||
[ 'id', '=', $id ],
|
||||
[ 'member_id', '=', $member_id ],
|
||||
[ 'site_id', '=', $site_id ]
|
||||
],
|
||||
'order_status,deposit_out_trade_no,final_out_trade_no'
|
||||
);
|
||||
|
||||
if (empty($order_info)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
//未支付定金
|
||||
if ($order_info[ 'order_status' ] == self::ORDER_CREATE) {
|
||||
return $this->success($order_info[ 'deposit_out_trade_no' ]);
|
||||
}
|
||||
|
||||
if ($order_info[ 'order_status' ] == self::WAIT_FINAL_PAY) {
|
||||
return $this->success($order_info[ 'final_out_trade_no' ]);
|
||||
}
|
||||
|
||||
return $this->error('', '请核实数据后重试');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单关闭
|
||||
* @param array $condition
|
||||
*/
|
||||
public function depositPresaleOrderClose($condition = [])
|
||||
{
|
||||
$list = model('promotion_presale_order')->getList($condition, 'id,order_status');
|
||||
if (empty($list)) {
|
||||
return $this->error('', '订单不存在');
|
||||
}
|
||||
foreach ($list as $key => $val) {
|
||||
if ($val[ 'order_status' ] != self::ORDER_CLOSE && $val[ 'order_status' ] != self::ORDER_CREATE) {
|
||||
$this->cronDepositOrderClose($val[ 'id' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
634
addon/presale/model/PresaleOrderCreate.php
Executable file
634
addon/presale/model/PresaleOrderCreate.php
Executable file
@@ -0,0 +1,634 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model;
|
||||
|
||||
use addon\coupon\model\Coupon;
|
||||
use addon\store\model\StoreGoodsSku;
|
||||
use addon\store\model\StoreMember as StoreMemberModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\express\Config as ExpressConfig;
|
||||
use app\model\express\Express;
|
||||
use app\model\express\Local;
|
||||
use app\model\order\Config;
|
||||
use app\model\order\OrderCreate;
|
||||
use app\model\order\OrderCreateTool;
|
||||
use app\model\store\Store;
|
||||
use app\model\system\Pay;
|
||||
use extend\exception\OrderException;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 订单创建(商品预售)
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class PresaleOrderCreate extends BaseModel
|
||||
{
|
||||
|
||||
use OrderCreateTool;
|
||||
|
||||
// private $goods_money = 0;//商品金额
|
||||
// private $balance_money = 0;//余额
|
||||
// private $delivery_money = 0;//配送费用
|
||||
// private $coupon_money = 0;//优惠券金额
|
||||
// private $adjust_money = 0;//调整金额
|
||||
// private $invoice_money = 0;//发票费用
|
||||
// private $promotion_money = 0;//优惠金额
|
||||
// private $order_money = 0;//订金金额
|
||||
// private $pay_money = 0;//支付总价
|
||||
//
|
||||
// private $is_virtual = 0; //是否是虚拟类订单
|
||||
// private $order_name = ''; //订单详情
|
||||
// private $goods_num = 0; //商品种数
|
||||
// private $member_balance_money = 0;//会员账户余额(计算过程中会逐次减少)
|
||||
// private $pay_type = 'ONLINE_PAY';//支付方式
|
||||
// private $invoice_delivery_money = 0;
|
||||
// private $error = 0; //是否有错误
|
||||
// private $error_msg = ''; //错误描述
|
||||
// private $recommend_member_card; // 推荐会员卡
|
||||
|
||||
|
||||
public $final_money = 0;//尾款金额
|
||||
public $presale_id = 0;
|
||||
public $deduction_money = 0;//抵扣金额
|
||||
public $promotion_presale_info = [];
|
||||
public $presale_info = [];
|
||||
public $pay_end_time = 0;
|
||||
public $is_deposit_back = 0;
|
||||
|
||||
/************************************************** 定金支付 start *********************************************************************/
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
* @param unknown $data
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//计算
|
||||
$this->confirm();
|
||||
if ($this->error > 0) {
|
||||
return $this->error(['error_code' => $this->error], $this->error_msg);
|
||||
}
|
||||
$pay = new Pay();
|
||||
$this->out_trade_no = $pay->createOutTradeNo($this->member_id);
|
||||
|
||||
$presale_common_order = new PresaleOrderCommon();
|
||||
$order_status_data = $presale_common_order->getOrderStatus();
|
||||
$order_status = $order_status_data['data'];
|
||||
$this->order_no = $this->createOrderNo();
|
||||
model('promotion_presale_order')->startTrans();
|
||||
//循环生成多个订单
|
||||
try {
|
||||
|
||||
$this->orderType();
|
||||
$express_type_list = $this->config('delivery_type');
|
||||
$delivery_type_name = $express_type_list[$this->delivery['delivery_type']] ?? '';
|
||||
|
||||
$sku_info = $this->goods_list[0];
|
||||
$data_order = [
|
||||
'site_id' => $this->site_id,
|
||||
'site_name' => $this->site_name,
|
||||
'presale_id' => $this->presale_id,
|
||||
'order_no' => $this->order_no,
|
||||
|
||||
'order_from' => $this->order_from,
|
||||
'order_from_name' => $this->order_from_name,
|
||||
'order_type' => $this->order_type['order_type_id'],
|
||||
'order_type_name' => $this->order_type['order_type_name'],
|
||||
'order_status_name' => $order_status[$presale_common_order::ORDER_CREATE]['name'],
|
||||
'order_status_action' => json_encode($order_status[$presale_common_order::ORDER_CREATE], JSON_UNESCAPED_UNICODE),
|
||||
'pay_start_time' => $this->presale_info['pay_start_time'],
|
||||
'pay_end_time' => $this->presale_info['pay_end_time'],
|
||||
|
||||
'goods_id' => $this->presale_info['goods_id'],
|
||||
'goods_name' => $this->presale_info['goods_name'],
|
||||
|
||||
'sku_id' => $sku_info['sku_id'],
|
||||
'sku_name' => $sku_info['sku_name'],
|
||||
'sku_image' => $sku_info['sku_image'],
|
||||
'sku_no' => $sku_info['sku_no'],
|
||||
'is_virtual' => $this->is_virtual,
|
||||
'goods_class' => $sku_info['goods_class'],
|
||||
'goods_class_name' => $sku_info['goods_class_name'],
|
||||
'cost_price' => $sku_info['cost_price'],
|
||||
'sku_spec_format' => $sku_info['sku_spec_format'],
|
||||
|
||||
'member_id' => $this->member_id,
|
||||
'name' => $this->delivery['member_address']['name'] ?? '',
|
||||
'mobile' => $this->delivery['member_address']['mobile'] ?? '',
|
||||
'telephone' => $this->delivery['member_address']['telephone'] ?? '',
|
||||
'province_id' => $this->delivery['member_address']['province_id'] ?? '',
|
||||
'city_id' => $this->delivery['member_address']['city_id'] ?? '',
|
||||
'district_id' => $this->delivery['member_address']['district_id'] ?? '',
|
||||
'community_id' => $this->delivery['member_address']['community_id'] ?? '',
|
||||
'address' => $this->delivery['member_address']['address'] ?? '',
|
||||
'full_address' => $this->delivery['member_address']['full_address'] ?? '',
|
||||
'longitude' => $this->delivery['member_address']['longitude'] ?? '',
|
||||
'latitude' => $this->delivery['member_address']['latitude'] ?? '',
|
||||
'buyer_ip' => request()->ip(),
|
||||
|
||||
'buyer_message' => $this->param['buyer_message'],
|
||||
|
||||
'num' => $this->goods_num,
|
||||
|
||||
|
||||
'price' => $sku_info['price'],
|
||||
'goods_money' => $this->goods_money,
|
||||
'balance_deposit_money' => $this->balance_money,
|
||||
|
||||
'delivery_money' => $this->delivery_money,
|
||||
'promotion_money' => $this->promotion_money,
|
||||
'coupon_id' => $this->coupon_id ?? 0,
|
||||
'coupon_money' => $this->coupon_money,
|
||||
'invoice_money' => $this->invoice_money,
|
||||
'invoice_delivery_money' => $this->invoice_delivery_money,
|
||||
|
||||
'order_money' => $this->order_money,
|
||||
'delivery_type' => $this->delivery['delivery_type'],
|
||||
'delivery_type_name' => $delivery_type_name,
|
||||
'delivery_store_id' => $this->delivery['store_id'] ?? 0,
|
||||
'delivery_store_name' => $this->delivery['delivery_store_name'] ?? '',
|
||||
'delivery_store_info' => $this->delivery['delivery_store_info'] ?? '',
|
||||
'buyer_ask_delivery_time' => $this->delivery['buyer_ask_delivery_time']['remark'] ?? '',//定时达
|
||||
'delivery_start_time' => $this->delivery['buyer_ask_delivery_time']['delivery_start_time'] ?? '',//配送开始时间
|
||||
'delivery_end_time' => $this->delivery['buyer_ask_delivery_time']['delivery_end_time'] ?? '',//配送结束时间
|
||||
|
||||
|
||||
'order_status' => '0',
|
||||
'create_time' => time(),
|
||||
|
||||
//预售相关
|
||||
'deposit_out_trade_no' => $this->out_trade_no,
|
||||
'is_deposit_back' => $this->promotion_presale_info['is_deposit_back'],
|
||||
'deposit_agreement' => $this->promotion_presale_info['deposit_agreement'],
|
||||
'presale_deposit' => $this->presale_info['presale_deposit'],//定金单价
|
||||
'presale_deposit_money' => $this->presale_deposit_money,//定金总额
|
||||
'presale_price' => $this->presale_info['presale_price'],//抵扣单价
|
||||
'presale_money' => $this->presale_money,//抵扣总额
|
||||
'pay_deposit_money' => $this->pay_money,
|
||||
'final_money' => $this->final_money,
|
||||
'is_fenxiao' => $this->presale_info['is_fenxiao'],
|
||||
|
||||
];
|
||||
if (isset($this->param['is_invoice']) && $this->param['is_invoice'] == 1) {
|
||||
$data_order = array_merge($data_order,
|
||||
[
|
||||
'is_invoice' => $this->param['is_invoice'] ?? 0,
|
||||
'invoice_type' => $this->invoice['invoice_type'] ?? 0,
|
||||
'invoice_title' => $this->invoice['invoice_title'] ?? '',
|
||||
'taxpayer_number' => $this->invoice['taxpayer_number'] ?? '',
|
||||
'invoice_rate' => $this->invoice['invoice_rate'] ?? 0,
|
||||
'invoice_content' => $this->invoice['invoice_content'] ?? '',
|
||||
'invoice_full_address' => $this->invoice['invoice_full_address'] ?? '',
|
||||
'is_tax_invoice' => $this->invoice['is_tax_invoice'] ?? '',
|
||||
'invoice_email' => $this->invoice['invoice_email'] ?? '',
|
||||
'invoice_title_type' => $this->invoice['invoice_title_type'] ?? 0
|
||||
]
|
||||
);
|
||||
}
|
||||
$this->order_id = model('promotion_presale_order')->add($data_order);
|
||||
|
||||
//预售订单创建
|
||||
event('PresaleOrderCreate', ['id' => $this->order_id]);
|
||||
|
||||
//添加门店关注记录和减少门店商品库存 最新代码位置
|
||||
$result_list = $this->addStoreMemberAndDecStock($data_order);
|
||||
if ($result_list['code'] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $result_list;
|
||||
}
|
||||
|
||||
//减少库存
|
||||
$stock_result = $this->decStock();
|
||||
if ($stock_result['code'] != 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $stock_result;
|
||||
}
|
||||
//使用余额
|
||||
$this->useBalance();
|
||||
//批量库存处理(卡密商品支付后在扣出库存)//todo 可以再商品中设置扣除库存步骤
|
||||
// $this->batchDecOrderGoodsStock();
|
||||
//添加门店关注记录和减少门店商品库存 原本代码位置
|
||||
|
||||
model('promotion_presale_order')->commit();
|
||||
//删除订单缓存
|
||||
$this->deleteOrderCache();
|
||||
//增加关闭订单自动事件
|
||||
$presale_order_model = new PresaleOrderCommon();
|
||||
$presale_order_model->addDepositOrderCronClose($this->order_id, $this->site_id);
|
||||
//如果退定金 增加尾款支付到期时间退定金操作
|
||||
if ($this->is_deposit_back == 0) {
|
||||
$presale_order_model->addRefundOrderCronClose($this->order_id, $this->site_id, $this->pay_end_time);
|
||||
}
|
||||
//生成整体支付单据
|
||||
$pay->addPay($this->site_id, $this->out_trade_no, $this->pay_type, $this->order_name, $this->order_name, $this->pay_money, '', 'DepositOrderPayNotify', '', $this->order_id, $this->member_id);
|
||||
return $this->success($this->out_trade_no);
|
||||
} catch ( \Exception $e ) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单计算(定金)
|
||||
* @param unknown $data
|
||||
*/
|
||||
public function depositCalculate()
|
||||
{
|
||||
$this->initMemberAddress(); //初始化地址
|
||||
$this->initMemberAccount();//初始化会员账户
|
||||
|
||||
$this->presale_id = $this->param['presale_id'];
|
||||
$sku_id = $this->param['sku_id'];
|
||||
$num = $this->param['num'];
|
||||
//查询预售活动信息
|
||||
$this->promotion_presale_info = model('promotion_presale')->getInfo([['presale_id', '=', $this->presale_id]]);
|
||||
if (empty($this->promotion_presale_info)) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '预售活动不存在!';
|
||||
}
|
||||
//查询预售信息
|
||||
$join = [
|
||||
['promotion_presale pp', 'pp.presale_id = ppg.presale_id', 'inner'],
|
||||
['goods g', 'g.goods_id = ppg.goods_id', 'inner']
|
||||
];
|
||||
$condition = [
|
||||
['ppg.presale_id', '=', $this->presale_id],
|
||||
['ppg.sku_id', '=', $sku_id],
|
||||
['g.goods_state', '=', 1],
|
||||
['g.is_delete', '=', 0]
|
||||
];
|
||||
$field = 'pp.*,ppg.sku_id,ppg.presale_stock,ppg.presale_deposit,ppg.presale_price,g.goods_name,g.is_virtual';
|
||||
$this->presale_info = model('promotion_presale_goods')->getInfo($condition, $field, 'ppg', $join);
|
||||
$this->is_virtual = $this->presale_info['is_virtual'];
|
||||
|
||||
if (empty($this->presale_info)) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '商品不存在!';
|
||||
}
|
||||
//判断活动是否过期或开启
|
||||
if ($this->presale_info['status'] != 1) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '当前商品预售活动未开启或已过期!';
|
||||
}
|
||||
//判断购买数是否超过限购
|
||||
if ($this->presale_info['presale_num'] < $num && $this->presale_info['presale_num'] > 0) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '该商品限制购买不能大于' . $this->presale_info['presale_num'] . '件!';
|
||||
}
|
||||
|
||||
//判断是否已存在订单
|
||||
$presale_order_count = model('promotion_presale_order')->getCount(
|
||||
[
|
||||
['member_id', '=', $this->member_id],
|
||||
['presale_id', '=', $this->presale_id],
|
||||
['order_status', '>=', 0],
|
||||
['refund_status', '=', 0]
|
||||
]);
|
||||
if ($presale_order_count > 0) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '预售期间,同一商品只可购买一次!';
|
||||
}
|
||||
|
||||
//商品列表信息
|
||||
$this->getOrderGoodsCalculate();
|
||||
//订单计算
|
||||
$this->shopOrderCalculate();
|
||||
|
||||
//定金金额
|
||||
$this->presale_deposit_money = $this->presale_info['presale_deposit'] * $num;
|
||||
//余额抵扣(判断是否使用余额)
|
||||
if ($this->member_balance_money > 0) {
|
||||
$balance_money = min($this->presale_deposit_money, $this->member_balance_money);
|
||||
} else {
|
||||
$balance_money = 0;
|
||||
}
|
||||
$this->pay_money = $this->presale_deposit_money - $balance_money;//计算出实际支付金额
|
||||
|
||||
$this->member_balance_money -= $balance_money;//预减少账户余额
|
||||
$this->balance_money += $balance_money;//累计余额
|
||||
|
||||
$this->order_money = $this->final_money + $this->presale_deposit_money;
|
||||
|
||||
$this->presale_money = $this->presale_info['presale_price'] * $this->goods_num;
|
||||
$this->is_deposit_back = $this->presale_info['is_deposit_back'];
|
||||
$this->pay_end_time = $this->presale_info['pay_end_time'];
|
||||
|
||||
//获取发票相关
|
||||
$this->getInovice();
|
||||
//todo 统一检测库存(创建订单操作时扣除库存同理)
|
||||
// 商品限购判断
|
||||
$this->checkLimitPurchase();
|
||||
$this->order_key = create_no();
|
||||
$this->setOrderCache(get_object_vars($this), $this->order_key);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 待付款订单(定金)
|
||||
* @param unknown $data
|
||||
*/
|
||||
public function depositOrderPayment()
|
||||
{
|
||||
$this->depositCalculate();
|
||||
$this->getDeliveryData();
|
||||
//订单初始项
|
||||
event('OrderPayment', ['order_object' => $this]);
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品的计算信息
|
||||
* @param unknown $data
|
||||
*/
|
||||
public function getOrderGoodsCalculate()
|
||||
{
|
||||
$this->getPresaleShopGoodsList();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取立即购买商品信息
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function getPresaleShopGoodsList()
|
||||
{
|
||||
$sku_id = $this->param['sku_id'];
|
||||
$num = $this->param['num'];
|
||||
$join = [
|
||||
['site ns', 'ngs.site_id = ns.site_id', 'inner']
|
||||
];
|
||||
$field = 'sku_id, sku_name, sku_no, price, discount_price,cost_price, stock, volume, weight, sku_image, ngs.site_id, goods_state, is_virtual, is_free_shipping, shipping_template,goods_class, goods_class_name, goods_id, ns.site_name,sku_spec_format,goods_name,max_buy,min_buy,support_trade_type, is_limit, limit_type,form_id';
|
||||
$sku_info = model('goods_sku')->getInfo([['sku_id', '=', $sku_id], ['ngs.site_id', '=', $this->site_id]], $field, 'ngs', $join);
|
||||
if (empty($sku_info)) throw new OrderException('不存在的商品!');
|
||||
|
||||
$price = $sku_info['price'];
|
||||
|
||||
$sku_info['num'] = $num;
|
||||
$goods_money = $price * $num;
|
||||
$sku_info['price'] = $price;
|
||||
$sku_info['goods_money'] = $goods_money;
|
||||
$sku_info['real_goods_money'] = $goods_money;
|
||||
$sku_info['coupon_money'] = 0; //优惠券金额
|
||||
$sku_info['promotion_money'] = 0; //优惠金额
|
||||
$sku_info['stock'] = numberFormat($sku_info['stock']);
|
||||
$goods_list[] = $sku_info;
|
||||
|
||||
$this->goods_money = $goods_money;
|
||||
$this->site_name = $sku_info['site_name'];
|
||||
$this->goods_list_str = $sku_info['sku_id'] . ':' . $sku_info['num'];
|
||||
$this->goods_list = $goods_list;
|
||||
$this->order_name = $sku_info['sku_name'];
|
||||
$this->goods_num = $sku_info['num'];
|
||||
$this->limit_purchase = [
|
||||
'goods_' . $sku_info['goods_id'] => [
|
||||
'goods_id' => $sku_info['goods_id'],
|
||||
'goods_name' => $sku_info['sku_name'],
|
||||
'num' => $sku_info['num'],
|
||||
'max_buy' => $sku_info['max_buy'],
|
||||
'min_buy' => $sku_info['min_buy'],
|
||||
'is_limit' => $sku_info['is_limit'],
|
||||
'limit_type' => $sku_info['limit_type'],
|
||||
]
|
||||
];
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存变化
|
||||
* @return array
|
||||
*/
|
||||
public function decStock()
|
||||
{
|
||||
$condition = array(
|
||||
['site_id', '=', $this->site_id],
|
||||
['presale_id', '=', $this->presale_id],
|
||||
['sku_id', '=', $this->goods_list[0]['sku_id']]
|
||||
);
|
||||
$presale_info = model('promotion_presale_goods')->getInfo($condition, 'presale_stock');
|
||||
if (empty($presale_info))
|
||||
return $this->error();
|
||||
|
||||
if ($presale_info['presale_stock'] <= 0)
|
||||
return $this->error('', '库存不足!');
|
||||
|
||||
//编辑sku库存
|
||||
$res = model('promotion_presale_goods')->setDec($condition, 'presale_stock', $this->goods_num);
|
||||
//减少总库存 2021.06.10
|
||||
if ($res === false)
|
||||
return $this->error();
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算后的进一步计算(不存缓存,每次都是重新计算)
|
||||
* @return array
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$order_key = $this->param['order_key'];
|
||||
$this->getOrderCache($order_key);
|
||||
//初始化地址
|
||||
$this->initMemberAddress();
|
||||
//初始化门店信息
|
||||
$this->initStore();
|
||||
//配送计算
|
||||
$this->is_check_buyer_ask_delivery_time = false;
|
||||
$this->calculateDelivery();
|
||||
//批量校验配送方式
|
||||
$this->batchCheckDeliveryType();
|
||||
//计算发票相关
|
||||
$this->calculateInvoice();
|
||||
//尾款金额
|
||||
$this->final_money = $this->final_money + $this->invoice_money + $this->invoice_delivery_money;
|
||||
//定金金额
|
||||
$this->presale_deposit_money = $this->presale_info['presale_deposit'] * $this->goods_num;
|
||||
//余额抵扣(判断是否使用余额)
|
||||
//使用余额
|
||||
$is_use_balance = $this->param['is_balance'] ?? 0;
|
||||
|
||||
if ($is_use_balance > 0) {
|
||||
//余额付款
|
||||
$this->member_balance_money = $this->member_account['balance_total'] ?? 0;
|
||||
if ($this->member_balance_money > 0) {
|
||||
$balance_money = min($this->presale_deposit_money, $this->member_balance_money);
|
||||
} else {
|
||||
$balance_money = 0;
|
||||
}
|
||||
$this->balance_money = $balance_money;
|
||||
}
|
||||
$this->pay_money = $this->presale_deposit_money - $this->balance_money;//计算出实际支付金额
|
||||
$this->member_balance_money -= $this->balance_money;//预减少账户余额
|
||||
$this->order_money = $this->final_money + $this->presale_deposit_money;
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单计算
|
||||
*/
|
||||
public function shopOrderCalculate()
|
||||
{
|
||||
|
||||
//实际抵扣金额
|
||||
if ($this->presale_info['presale_price'] == 0) {//全款预售
|
||||
$this->deduction_money = 0;
|
||||
} else {
|
||||
$this->deduction_money = $this->presale_info['presale_price'] * $this->goods_num - $this->presale_info['presale_deposit'] * $this->goods_num;
|
||||
}
|
||||
//尾款金额
|
||||
$this->final_money = $this->goods_money - $this->presale_info['presale_deposit'] * $this->goods_num - $this->promotion_money - $this->deduction_money + $this->delivery_money;
|
||||
|
||||
//理论上是多余的操作
|
||||
if ($this->final_money < 0) {
|
||||
$this->final_money = 0;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加门店关注记录和减少门店商品库存
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addStoreMemberAndDecStock($data)
|
||||
{
|
||||
if (!empty($data['delivery_store_id'])) {
|
||||
//添加店铺关注记录
|
||||
$shop_member_model = new StoreMemberModel();
|
||||
$res = $shop_member_model->addStoreMember($data['delivery_store_id'], $data['member_id']);
|
||||
if ($res['code'] < 0) {
|
||||
return $res;
|
||||
}
|
||||
$stock_result = $this->skuDecStock($data, $data['delivery_store_id']);
|
||||
if ($stock_result['code'] < 0) {
|
||||
|
||||
return $stock_result;
|
||||
}
|
||||
// $store_goods_sku_model = new StoreGoodsSku();
|
||||
// $stock_result = $store_goods_sku_model->decStock([ 'store_id' => $data[ 'delivery_store_id' ], 'sku_id' => $data[ 'sku_id' ], 'stock' => $data[ 'num' ] ]);
|
||||
// if ($stock_result[ 'code' ] < 0) {
|
||||
// return $this->error('', '当前门店库存不足,请选择其他门店');
|
||||
// }
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
/************************************************** 定金支付 end *********************************************************************/
|
||||
|
||||
/************************************************** 尾款支付 start *********************************************************************/
|
||||
|
||||
/**
|
||||
* 订单计算(尾款)
|
||||
* @param unknown $data
|
||||
*/
|
||||
public function finalCalculate($data)
|
||||
{
|
||||
$this->initMemberAccount();//初始化会员账户
|
||||
//余额付款
|
||||
if ($data['is_balance'] > 0) {
|
||||
$this->member_balance_money = $this->member_account['balance_total'] ?? 0;
|
||||
}
|
||||
//查询预售订单信息
|
||||
$presale_order_model = new PresaleOrder();
|
||||
$order_info = $presale_order_model->getPresaleOrderInfo([['id', '=', $data['id']], ['site_id', '=', $this->site_id]])['data'] ?? [];
|
||||
|
||||
$data['order_info'] = $order_info;
|
||||
|
||||
//判断是否可以支付尾款
|
||||
if ($order_info['pay_start_time'] > time()) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '尾款支付时间还未开始!';
|
||||
}
|
||||
if ($order_info['pay_end_time'] < time()) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '尾款支付时间已过,已停止支付!';
|
||||
}
|
||||
|
||||
//尾款总金额(尾款实际金额 + 发票 + 物流等)
|
||||
$order_money = $order_info['final_money'];
|
||||
|
||||
//余额抵扣(判断是否使用余额)
|
||||
if ($this->member_balance_money > 0) {
|
||||
if ($order_money <= $this->member_balance_money) {
|
||||
$balance_money = $order_money;
|
||||
} else {
|
||||
$balance_money = $this->member_balance_money;
|
||||
}
|
||||
} else {
|
||||
$balance_money = 0;
|
||||
}
|
||||
$pay_money = $order_money - $balance_money;//计算出实际支付金额
|
||||
$this->member_balance_money -= $balance_money;//预减少账户余额
|
||||
$this->balance_money += $balance_money;//累计余额
|
||||
$is_use = 1;
|
||||
|
||||
$this->pay_money += $pay_money;
|
||||
//总结计算
|
||||
$data['balance_final_money'] = $this->balance_money;
|
||||
$data['pay_final_money'] = $this->pay_money;
|
||||
$data['is_use_balance'] = $is_use;
|
||||
$data['balance_money'] = $this->balance_money;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 尾款支付
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function payfinalMoneyPresaleOrder($data)
|
||||
{
|
||||
//查询出会员相关信息
|
||||
$calculate_data = $this->finalCalculate($data);
|
||||
if (isset($calculate_data['code']) && $calculate_data['code'] < 0)
|
||||
return $calculate_data;
|
||||
if ($this->error > 0) {
|
||||
return $this->error(['error_code' => $this->error], $this->error_msg);
|
||||
}
|
||||
$pay = new Pay();
|
||||
$out_trade_no = $pay->createOutTradeNo();
|
||||
$order_data = [
|
||||
'balance_final_money' => $calculate_data['balance_final_money'],
|
||||
'pay_final_money' => $calculate_data['pay_final_money'],
|
||||
'final_out_trade_no' => $out_trade_no,
|
||||
];
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
model('promotion_presale_order')->update($order_data, [['site_id', '=', $data['site_id']], ['id', '=', $data['id']]]);
|
||||
$this->order_id = $data['id'];
|
||||
//扣除余额(统一扣除)
|
||||
$this->order_from_type = 'presale_order';
|
||||
$this->useBalance();
|
||||
$order_name = $calculate_data['order_info']['sku_name'];
|
||||
//生成整体支付单据
|
||||
$pay->addPay($data['site_id'], $out_trade_no, $this->pay_type, $order_name, $order_name, $this->pay_money, '', 'FinalOrderPayNotify', '', $this->order_id, $this->member_id);
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success($out_trade_no);
|
||||
} catch ( \Exception $e ) {
|
||||
model()->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************** 尾款支付 end *********************************************************************/
|
||||
|
||||
}
|
||||
402
addon/presale/model/PresaleOrderRefund.php
Executable file
402
addon/presale/model/PresaleOrderRefund.php
Executable file
@@ -0,0 +1,402 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model;
|
||||
|
||||
use app\dict\member_account\AccountDict;
|
||||
use app\model\member\MemberAccount;
|
||||
use app\model\BaseModel;
|
||||
use addon\coupon\model\Coupon;
|
||||
use app\model\system\Pay;
|
||||
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class PresaleOrderRefund extends BaseModel
|
||||
{
|
||||
//已申请退款
|
||||
const REFUND_APPLY = 1;
|
||||
//已完成
|
||||
const REFUND_COMPLETE = 2;
|
||||
//已拒绝
|
||||
const REFUND_REFUSE = -1;
|
||||
|
||||
/**
|
||||
* 订单退款状态
|
||||
* @var unknown
|
||||
*/
|
||||
public $order_refund_status = [
|
||||
self::REFUND_APPLY => [
|
||||
'status' => self::REFUND_APPLY,
|
||||
'name' => '申请退款',
|
||||
],
|
||||
self::REFUND_COMPLETE => [
|
||||
'status' => self::REFUND_COMPLETE,
|
||||
'name' => '退款成功',
|
||||
],
|
||||
self::REFUND_REFUSE => [
|
||||
'status' => self::REFUND_REFUSE,
|
||||
'name' => '退款拒绝',
|
||||
]
|
||||
];
|
||||
|
||||
/*************************************************************************** 用户申请退款操作(start)**********************************/
|
||||
|
||||
/**
|
||||
* 用户申请退款
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function applyRefund($data)
|
||||
{
|
||||
$order_info = model('promotion_presale_order')->getInfo(
|
||||
[
|
||||
[ 'id', '=', $data[ 'id' ] ],
|
||||
[ 'site_id', '=', $data[ 'site_id' ] ]
|
||||
],
|
||||
'pay_end_time,order_status,refund_status,member_id,balance_final_money,pay_final_money'
|
||||
);
|
||||
|
||||
if (empty($order_info) || $order_info[ 'member_id' ] != $data[ 'member_id' ]) {
|
||||
return $this->error('', '非法请求!');
|
||||
}
|
||||
//不能重复申请退款
|
||||
if ($order_info[ 'refund_status' ] == self::REFUND_APPLY) {
|
||||
return $this->error('', '请不要重复申请退款');
|
||||
}
|
||||
|
||||
//支付尾款了不能申请退款
|
||||
if ($order_info[ 'order_status' ] != PresaleOrderCommon::WAIT_FINAL_PAY) {
|
||||
return $this->error();
|
||||
}
|
||||
|
||||
$pay_model = new Pay();
|
||||
$refund_no = $pay_model->createRefundNo();
|
||||
|
||||
if ($order_info[ 'refund_status' ] == self::REFUND_REFUSE) {
|
||||
$order_data = [
|
||||
'refund_status' => self::REFUND_APPLY,
|
||||
'refund_status_name' => $this->order_refund_status[ self::REFUND_APPLY ][ 'name' ],
|
||||
];
|
||||
} else {
|
||||
$order_data = [
|
||||
'deposit_refund_no' => $refund_no,
|
||||
'refund_status' => self::REFUND_APPLY,
|
||||
'refund_status_name' => $this->order_refund_status[ self::REFUND_APPLY ][ 'name' ],
|
||||
'apply_refund_time' => time(),
|
||||
];
|
||||
}
|
||||
|
||||
$res = model('promotion_presale_order')->update($order_data, [ [ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户取消申请退款
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function cancelRefund($condition = [])
|
||||
{
|
||||
$order_info = model('promotion_presale_order')->getInfo(
|
||||
$condition,
|
||||
'pay_end_time,order_status,refund_status,'
|
||||
);
|
||||
|
||||
if (empty($order_info)) {
|
||||
return $this->error('', '非法请求!');
|
||||
}
|
||||
|
||||
//不能重复申请退款
|
||||
if ($order_info[ 'refund_status' ] != self::REFUND_APPLY) {
|
||||
return $this->error('', '已退款或已取消');
|
||||
}
|
||||
|
||||
$order_data = [
|
||||
'deposit_refund_no' => '',
|
||||
'refund_status' => '',
|
||||
'refund_status_name' => '',
|
||||
'apply_refund_time' => '',
|
||||
];
|
||||
|
||||
$res = model('promotion_presale_order')->update($order_data, $condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拒绝退款
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function refuseRefund($data)
|
||||
{
|
||||
$order_info = model('promotion_presale_order')->getInfo(
|
||||
[
|
||||
[ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ]
|
||||
]
|
||||
, 'refund_status'
|
||||
);
|
||||
|
||||
if ($order_info[ 'refund_status' ] == self::REFUND_REFUSE) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
$order_data = [
|
||||
'refund_status' => self::REFUND_REFUSE,
|
||||
'refund_status_name' => $this->order_refund_status[ self::REFUND_REFUSE ][ 'name' ],
|
||||
'refuse_reason' => $data[ 'refuse_reason' ],
|
||||
'refund_time' => time()
|
||||
];
|
||||
|
||||
$res = model('promotion_presale_order')->update($order_data, [ [ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意退款
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function agreeRefund($data)
|
||||
{
|
||||
$order_info = model('promotion_presale_order')->getInfo(
|
||||
[
|
||||
[ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ]
|
||||
]
|
||||
);
|
||||
|
||||
if ($order_info[ 'refund_status' ] == self::REFUND_COMPLETE) {
|
||||
return $this->success();
|
||||
}
|
||||
if ($order_info[ 'order_status' ] == 1 && $order_info[ 'pay_end_time' ] < time()) {
|
||||
$pay_model = new Pay();
|
||||
$refund_no = $pay_model->createRefundNo();
|
||||
}
|
||||
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
|
||||
//增加库存
|
||||
// model('promotion_presale')->setInc([['presale_id', '=', $order_info['presale_id']]], 'presale_stock', $order_info['num']);
|
||||
|
||||
//增加门店库存
|
||||
if ($order_info[ 'delivery_store_id' ] > 0) {
|
||||
$presale_order_common = new PresaleOrderCommon();
|
||||
$store_data = [
|
||||
'delivery_store_id' => $order_info[ 'delivery_store_id' ],
|
||||
'num' => $order_info[ 'num' ],
|
||||
'sku_id' => $order_info[ 'sku_id' ]
|
||||
];
|
||||
$store_result = $presale_order_common->incStoreGoodsStock($store_data);
|
||||
if ($store_result[ 'code' ] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $store_result;
|
||||
}
|
||||
}
|
||||
|
||||
//返还店铺优惠券
|
||||
$coupon_id = $order_info[ "coupon_id" ];
|
||||
if ($coupon_id > 0) {
|
||||
$coupon_model = new Coupon();
|
||||
$coupon_model->refundCoupon($coupon_id, $order_info[ "member_id" ]);
|
||||
}
|
||||
//平台优惠券
|
||||
|
||||
//平台余额 退还余额(定金余额)
|
||||
$balance_money = 0;
|
||||
$deposit_money = 0;//退款定金金额(余额支付+现金支付)
|
||||
if ($order_info[ "balance_deposit_money" ] > 0) {
|
||||
$balance_money += $order_info[ "balance_deposit_money" ];
|
||||
$deposit_money += $order_info[ "balance_deposit_money" ];
|
||||
}
|
||||
if ($order_info[ "balance_final_money" ] > 0) {
|
||||
$balance_money += $order_info[ "balance_final_money" ];
|
||||
}
|
||||
if ($balance_money > 0) {
|
||||
|
||||
$member_account_model = new MemberAccount();
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ "member_id" ], AccountDict::balance, $balance_money, "presale_deposit_refund", "余额返还", "订单关闭返还");
|
||||
}
|
||||
|
||||
//现金原路退还
|
||||
if ($order_info[ "pay_deposit_money" ] > 0) {
|
||||
$pay_model = new Pay();
|
||||
$refund_result = $pay_model->refund($order_info[ "deposit_refund_no" ], $order_info[ 'pay_deposit_money' ], $order_info[ "deposit_out_trade_no" ], '', $order_info[ 'pay_deposit_money' ], $order_info[ "site_id" ], 1);
|
||||
if ($refund_result[ "code" ] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $refund_result;
|
||||
}
|
||||
}
|
||||
|
||||
$order_common = new PresaleOrderCommon();
|
||||
//修改订单退款状态
|
||||
$order_data = [
|
||||
'order_status' => $order_common::ORDER_CLOSE,
|
||||
'order_status_name' => $order_common->order_status[ $order_common::ORDER_CLOSE ][ 'name' ],
|
||||
'order_status_action' => json_encode($order_common->order_status[ $order_common::ORDER_CLOSE ], JSON_UNESCAPED_UNICODE),
|
||||
'refund_status' => self::REFUND_COMPLETE,
|
||||
'refund_status_name' => $this->order_refund_status[ self::REFUND_COMPLETE ][ 'name' ],
|
||||
// 'refund_money' => $balance_money + $order_info["pay_deposit_money"],
|
||||
'refund_money' => $deposit_money + $order_info[ "pay_deposit_money" ],
|
||||
'refund_time' => time(),
|
||||
];
|
||||
if (isset($refund_no) && !empty($refund_no)) {
|
||||
$order_data[ 'deposit_refund_no' ] = $refund_no;
|
||||
}
|
||||
model('promotion_presale_order')->update($order_data, [ [ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $data[ 'site_id' ] ] ]);
|
||||
|
||||
//减少预约数量
|
||||
model('promotion_presale')->setDec([ [ 'presale_id', '=', $order_info[ 'presale_id' ] ] ], 'sale_num', $order_info[ 'num' ]);
|
||||
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************** 用户申请退款操作(end)**********************************/
|
||||
|
||||
/*************************************************************************** 订单退款相关操作(start)**********************************/
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* @param $order_no
|
||||
* @param $is_deposit_back
|
||||
* @param $refund_money_type
|
||||
* @return array|mixed|void
|
||||
*/
|
||||
public function refundPresaleOrder($order_no, $is_deposit_back, $refund_money_type)
|
||||
{
|
||||
//$refund_money_type 1原路退款 2线下退款 3退款到余额
|
||||
//$is_deposit_back 0:退定金 1:不退定金
|
||||
|
||||
|
||||
$is_offline = 1;
|
||||
//是否线下退款
|
||||
if ($refund_money_type == 2) {
|
||||
$is_offline = 2;
|
||||
}
|
||||
|
||||
$order_info = model('promotion_presale_order')->getInfo(
|
||||
[
|
||||
[ 'order_no', '=', $order_no ]
|
||||
]
|
||||
);
|
||||
$order_goods_info = model('order_goods')->getInfo(
|
||||
[
|
||||
[ 'order_no', '=', $order_no ]
|
||||
],
|
||||
'refund_action_time'
|
||||
);
|
||||
if (empty($order_info)) {
|
||||
return $this->success();
|
||||
}
|
||||
if ($order_info[ 'refund_status' ] == self::REFUND_COMPLETE) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
model('promotion_presale_order')->startTrans();
|
||||
try {
|
||||
|
||||
//修改订单退款状态
|
||||
$pay_model = new Pay();
|
||||
$deposit_refund_no = $pay_model->createRefundNo();
|
||||
$final_refund_no = $pay_model->createRefundNo();
|
||||
$balance_money = 0;
|
||||
|
||||
if ($refund_money_type == 1) {//原路退款
|
||||
//在线支付定金原路退还
|
||||
if ($order_info[ "pay_deposit_money" ] > 0 && $is_deposit_back == 1 && $is_offline == 1) {
|
||||
$pay_model = new Pay();
|
||||
$refund_result = $pay_model->refund($deposit_refund_no, $order_info[ 'pay_deposit_money' ], $order_info[ "deposit_out_trade_no" ], '', $order_info[ 'pay_deposit_money' ], $order_info[ "site_id" ], 1);
|
||||
if ($refund_result[ "code" ] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $refund_result;
|
||||
}
|
||||
}
|
||||
//在线支付尾款原路退还
|
||||
if ($order_info[ "pay_final_money" ] > 0 && $is_offline == 1) {
|
||||
$pay_model = new Pay();
|
||||
$refund_result = $pay_model->refund($final_refund_no, $order_info[ 'pay_final_money' ], $order_info[ "final_out_trade_no" ], '', $order_info[ 'pay_final_money' ], $order_info[ "site_id" ], 1);
|
||||
if ($refund_result[ "code" ] < 0) {
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $refund_result;
|
||||
}
|
||||
}
|
||||
//余额支付定金原路退还
|
||||
if ($order_info[ "balance_deposit_money" ] > 0 && $is_deposit_back == 1) {
|
||||
$balance_money += $order_info[ "balance_deposit_money" ];
|
||||
}
|
||||
//余额支付尾款原路退还
|
||||
if ($order_info[ "balance_final_money" ] > 0) {
|
||||
$balance_money += $order_info[ "balance_final_money" ];
|
||||
}
|
||||
if ($balance_money > 0 && $is_offline == 1) {
|
||||
$member_account_model = new MemberAccount();
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ "member_id" ], AccountDict::balance, $balance_money, "presale_refund", "余额返还", "订单关闭返还");
|
||||
}
|
||||
|
||||
} elseif ($refund_money_type == 3) {//退款到余额
|
||||
|
||||
$balance_money += $order_info[ 'final_money' ];
|
||||
if ($is_deposit_back == 1) {
|
||||
$balance_money += $order_info[ 'presale_deposit_money' ];
|
||||
}
|
||||
$member_account_model = new MemberAccount();
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ "member_id" ], AccountDict::balance, $balance_money, "presale_refund", "余额返还", "订单关闭返还");
|
||||
|
||||
}
|
||||
|
||||
$refund_money = 0;
|
||||
$refund_money += $order_info[ 'final_money' ];
|
||||
if ($is_deposit_back == 1) {
|
||||
$refund_money += $order_info[ 'presale_deposit_money' ];
|
||||
}
|
||||
|
||||
$order_common = new PresaleOrderCommon();
|
||||
$order_data = [
|
||||
'order_status' => $order_common::ORDER_CLOSE,
|
||||
'order_status_name' => $order_common->order_status[ $order_common::ORDER_CLOSE ][ 'name' ],
|
||||
'order_status_action' => json_encode($order_common->order_status[ $order_common::ORDER_CLOSE ], JSON_UNESCAPED_UNICODE),
|
||||
'deposit_refund_no' => $deposit_refund_no,
|
||||
'final_refund_no' => $final_refund_no,
|
||||
'refund_status' => self::REFUND_COMPLETE,
|
||||
'refund_status_name' => $this->order_refund_status[ self::REFUND_COMPLETE ][ 'name' ],
|
||||
// 'refund_money' => $order_info["pay_deposit_money"] + $order_info["pay_final_money"] + $balance_money,
|
||||
'refund_money' => $refund_money,
|
||||
'refuse_time' => time(),
|
||||
'apply_refund_time' => $order_goods_info[ 'refund_action_time' ]
|
||||
];
|
||||
|
||||
model('promotion_presale_order')->update($order_data, [ [ 'order_no', '=', $order_no ] ]);
|
||||
model('promotion_presale_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('promotion_presale_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************** 订单退款相关操作(end)**********************************/
|
||||
|
||||
}
|
||||
142
addon/presale/model/share/WchatShare.php
Executable file
142
addon/presale/model/share/WchatShare.php
Executable file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model\share;
|
||||
|
||||
use addon\presale\model\Presale as PresaleModel;
|
||||
use app\model\share\WchatShareBase as BaseModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WchatShare extends BaseModel
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '预售分享',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_PRESALE_PROMOTE',
|
||||
'path' => [ '/pages_promotion/presale/detail' ],
|
||||
'method_prefix' => 'goodsDetail',
|
||||
],
|
||||
[
|
||||
'title' => '预售列表',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_PRESALE_LIST_PROMOTE',
|
||||
'path' => [ '/pages_promotion/presale/list' ],
|
||||
'method_prefix' => 'goodsList',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 7;
|
||||
|
||||
/**
|
||||
* 预售列表
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsListShareData($param)
|
||||
{
|
||||
//跳转路径
|
||||
$link = $this->getShareLink($param);
|
||||
$config_data = $this->goodsListShareConfig($param)[ 'value' ];
|
||||
|
||||
$data = [
|
||||
'link' => $link,
|
||||
'desc' => $config_data[ 'desc' ],
|
||||
'imgUrl' => $config_data[ 'imgUrl' ],
|
||||
'title' => $config_data[ 'title' ]
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 预售列表分享配置
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function goodsListShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => "预售列表",
|
||||
'desc' => "预先抢购\n优惠更多",
|
||||
'imgUrl' => ''
|
||||
];
|
||||
}
|
||||
if (empty($data[ 'value' ][ 'imgUrl' ])) {
|
||||
$data[ 'value' ][ 'imgUrl' ] = img('addon/presale/icon.png');
|
||||
}
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 预售分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsDetailShareData($param)
|
||||
{
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
$url = $param[ 'url' ];
|
||||
|
||||
$parse_res = parse_url($url);
|
||||
parse_str($parse_res[ 'query' ] ?? '', $query);
|
||||
|
||||
if (isset($query[ 'id' ])) {
|
||||
$id = $query[ 'id' ];
|
||||
$presale_model = new PresaleModel();
|
||||
$condition = [
|
||||
[ 'pp.presale_id', '=', $id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$presale_info = $presale_model->getPresaleGoodsDetail($condition)[ 'data' ];
|
||||
if (!empty($presale_info)) {
|
||||
$config_model = new \app\model\share\WchatShare();
|
||||
$config_data = $config_model->goodsDetailShareConfig($param);
|
||||
|
||||
$title = str_replace('{goods_name}', $presale_info[ 'sku_name' ], $config_data[ 'value' ][ 'title' ]);
|
||||
$desc = str_replace('{price}', $presale_info[ 'presale_deposit' ], $config_data[ 'value' ][ 'desc' ]);
|
||||
$link = $parse_res[ 'scheme' ] . '://' . $parse_res[ 'host' ] . $parse_res[ 'path' ] . '?id=' . $id;
|
||||
if (!empty($member_id)) $link .= '&source_member=' . $member_id;
|
||||
$image_url = $presale_info[ 'sku_image' ];
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
'link' => $link,
|
||||
'imgUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
addon/presale/model/share/WeappShare.php
Executable file
89
addon/presale/model/share/WeappShare.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\model\share;
|
||||
|
||||
use app\model\share\WeappShareBase;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WeappShare extends WeappShareBase
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '预售列表',
|
||||
'config_key' => 'WEAPP_SHARE_CONFIG_PRESALE_LIST',
|
||||
'path' => [ '/pages_promotion/presale/list' ],
|
||||
'method_prefix' => 'presaleList',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 8;
|
||||
|
||||
/**
|
||||
* 预售列表
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function presaleListShareData($param)
|
||||
{
|
||||
//获取和替换配置数据
|
||||
$config_data = $this->presaleListShareConfig($param);
|
||||
$title = $config_data[ 'value' ][ 'title' ];
|
||||
$image_url = $config_data[ 'value' ][ 'imageUrl' ] ? img($config_data[ 'value' ][ 'imageUrl' ]) : '';
|
||||
$path = $this->getSharePath($param);
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'path' => $path,
|
||||
'imageUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'onShareAppMessage' => true,
|
||||
'onShareTimeline' => true,
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 预售列表
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function presaleListShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'app_module', '=', 'shop' ],
|
||||
[ 'config_key', '=', $config[ 'config_key' ] ],
|
||||
])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => '预先抢购更优惠哦!',
|
||||
'imageUrl' => '',
|
||||
];
|
||||
}
|
||||
$variable = [];
|
||||
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
'variable' => $variable,
|
||||
];
|
||||
}
|
||||
}
|
||||
226
addon/presale/shop/controller/Order.php
Executable file
226
addon/presale/shop/controller/Order.php
Executable file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\shop\controller;
|
||||
|
||||
use addon\presale\model\PresaleOrder;
|
||||
use addon\presale\model\PresaleOrderCommon;
|
||||
use app\shop\controller\BaseShop;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 预售订单
|
||||
*/
|
||||
class Order extends BaseShop
|
||||
{
|
||||
|
||||
/*
|
||||
* 订单列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$presale_id = input('presale_id', 0);
|
||||
$presale_order_model = new PresaleOrder();
|
||||
$condition = [
|
||||
[ 'ppo.site_id', '=', $this->site_id ],
|
||||
// [ 'ppo.refund_status', '=', 0 ]
|
||||
];
|
||||
if ($presale_id > 0) {
|
||||
$condition[] = [ 'ppo.presale_id', '=', $presale_id ];
|
||||
}
|
||||
//获取续签信息
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
//搜索类型(订单号、商品名称)
|
||||
$order_label = input('order_label', 'order_no');
|
||||
$search = input('search', '');
|
||||
if ($search) {
|
||||
$condition[] = [ 'ppo.' . $order_label, 'like', '%' . $search . '%' ];
|
||||
}
|
||||
//订单状态
|
||||
$order_status = input('order_status', '');
|
||||
if ($order_status !== '') {
|
||||
$condition[] = [ 'ppo.order_status', '=', $order_status ];
|
||||
}
|
||||
//订单来源
|
||||
$order_from = input("order_from", '');
|
||||
if ($order_from) {
|
||||
$condition[] = [ "ppo.order_from", "=", $order_from ];
|
||||
}
|
||||
//定金支付方式
|
||||
$deposit_pay_type = input("deposit_pay_type", '');
|
||||
if ($deposit_pay_type) {
|
||||
$condition[] = [ "ppo.deposit_pay_type", "=", $deposit_pay_type ];
|
||||
}
|
||||
//尾款支付方式
|
||||
$final_pay_type = input("final_pay_type", '');
|
||||
if ($final_pay_type) {
|
||||
$condition[] = [ "ppo.final_pay_type", "=", $final_pay_type ];
|
||||
}
|
||||
//订单类型
|
||||
$order_type = input('order_type', '');
|
||||
if ($order_type && $order_type != 'all') {
|
||||
$condition[] = [ "ppo.order_type", "=", $order_type ];
|
||||
}
|
||||
//创建时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && $end_time) {
|
||||
$condition[] = [ 'ppo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'ppo.create_time', '<=', date_to_time($end_time) ];
|
||||
|
||||
} elseif ($start_time && !$end_time) {
|
||||
$condition[] = [ 'ppo.create_time', '>=', date_to_time($start_time) ];
|
||||
}
|
||||
|
||||
$list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size, 'id desc');
|
||||
|
||||
if (!empty($list[ 'data' ][ 'list' ])) {
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$action_array = json_decode($v[ 'order_status_action' ], true);
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'action' ] = $action_array[ 'action' ];
|
||||
if ($v[ 'pay_end_time' ] < time()) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'can_refund' ] = 1;
|
||||
} else {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'can_refund' ] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
} else {
|
||||
//搜索方式
|
||||
$order_label_list = array (
|
||||
"order_no" => "订单号",
|
||||
"goods_name" => "商品名称",
|
||||
"name" => "收货人姓名",
|
||||
"mobile" => "收货人手机号",
|
||||
);
|
||||
$this->assign('order_label_list', $order_label_list);
|
||||
//订单状态
|
||||
$order_model = new PresaleOrderCommon();
|
||||
$order_status_list = $order_model->order_status;
|
||||
$this->assign("order_status_list", $order_status_list);
|
||||
|
||||
//订单来源 (支持端口)
|
||||
$order_from = Config::get("app_type");
|
||||
$this->assign('order_from_list', $order_from);
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$order_type_list = $order_common_model->getOrderTypeStatusList();
|
||||
$this->assign("order_type_list", $order_type_list);
|
||||
|
||||
$pay_type = $order_common_model->getPayType();
|
||||
$this->assign("pay_type_list", $pay_type);
|
||||
|
||||
$this->assign('presale_id', $presale_id);
|
||||
|
||||
return $this->fetch("order/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$presale_order_model = new PresaleOrder();
|
||||
|
||||
$id = input('id', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'id', '=', $id ]
|
||||
];
|
||||
|
||||
$info = $presale_order_model->getPresaleOrderInfo($condition);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到订单数据', href_url('presale://shop/order/lists'));
|
||||
$this->assign('order_detail', $info[ 'data' ]);
|
||||
|
||||
return $this->fetch("order/detail");
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('order_id');
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
|
||||
$res = $order_common_model->depositOrderClose($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
*/
|
||||
public function deleteOrder()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$id = input('order_id');
|
||||
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
|
||||
$res = $order_common_model->deleteOrder($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付定金
|
||||
*/
|
||||
public function offlinePayDeposit()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$id = input('order_id');
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
|
||||
$res = $order_common_model->offlinePayDeposit($id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付尾款
|
||||
*/
|
||||
public function offlinePayFinal()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$id = input('order_id');
|
||||
$order_common_model = new PresaleOrderCommon();
|
||||
|
||||
$res = $order_common_model->offlinePayFinal($id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
259
addon/presale/shop/controller/Presale.php
Executable file
259
addon/presale/shop/controller/Presale.php
Executable file
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\presale\model\Presale as PresaleModel;
|
||||
|
||||
class Presale extends BaseShop
|
||||
{
|
||||
|
||||
/*
|
||||
* 预售商品列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new PresaleModel();
|
||||
|
||||
$condition = [
|
||||
[ 'p.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$status = input('status', '');//预售状态
|
||||
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'p.status', '=', $status ];
|
||||
}
|
||||
//商品名称
|
||||
$goods_name = input('goods_name', '');
|
||||
if ($goods_name) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $goods_name . '%' ];
|
||||
}
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'p.end_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'p.start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$start_timestamp = date_to_time($start_time);
|
||||
$end_timestamp = date_to_time($end_time);
|
||||
$sql = "p.start_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or p.end_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or (p.start_time <= {$start_timestamp} and p.end_time >= {$end_timestamp})";
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
|
||||
}
|
||||
|
||||
$order_by = 'p.create_time desc';
|
||||
$list = $model->getPresalePageList($condition, $page, $page_size, $order_by);
|
||||
return $list;
|
||||
} else {
|
||||
$presale_status = $model->getPresaleStatus();
|
||||
$this->assign('presale_status', $presale_status[ 'data' ]);
|
||||
|
||||
return $this->fetch("presale/lists");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$common_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'presale_name' => input('presale_name', ''),//活动名称
|
||||
'start_time' => strtotime(input('start_time', '')),//活动时间
|
||||
'end_time' => strtotime(input('end_time', '')),//活动时间
|
||||
'pay_start_time' => strtotime(input('pay_start_time', '')),//尾款支付时间
|
||||
'pay_end_time' => strtotime(input('pay_end_time', '')),//尾款支付时间
|
||||
'presale_num' => input('presale_num', ''),//限购
|
||||
'deliver_type' => input('deliver_type', ''),//发货方式
|
||||
'deliver_time' => input('deliver_time', ''),//发货时间
|
||||
'is_fenxiao' => input('is_fenxiao', ''),//是否参与分销
|
||||
'is_deposit_back' => input('is_deposit_back', ''),//是否支持退定金
|
||||
'deposit_agreement' => input('deposit_agreement', ''),//退定金协议
|
||||
'remark' => input('remark', ''),//活动规则说明
|
||||
];
|
||||
if ($common_data[ 'deliver_type' ] == 0) {
|
||||
$common_data[ 'deliver_time' ] = strtotime($common_data[ 'deliver_time' ]);
|
||||
}
|
||||
if ($common_data[ 'is_deposit_back' ] == 0) {
|
||||
$common_data[ 'deposit_agreement' ] = '';
|
||||
}
|
||||
$goods = [
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
];
|
||||
$sku_list = input('sku_list', '');
|
||||
$presale_model = new PresaleModel();
|
||||
return $presale_model->addPresale($common_data, $goods, $sku_list);
|
||||
} else {
|
||||
$presale_name = '预售 ' . date('Y-m-d');
|
||||
$this->assign('presale_name', $presale_name);
|
||||
return $this->fetch("presale/add");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$presale_model = new PresaleModel();
|
||||
|
||||
$presale_id = input('presale_id', '');
|
||||
if (request()->isJson()) {
|
||||
|
||||
$common_data = [
|
||||
'presale_id' => $presale_id,
|
||||
'site_id' => $this->site_id,
|
||||
'presale_name' => input('presale_name', ''),//活动名称
|
||||
'start_time' => strtotime(input('start_time', '')),//活动时间
|
||||
'end_time' => strtotime(input('end_time', '')),//活动时间
|
||||
'pay_start_time' => strtotime(input('pay_start_time', '')),//尾款支付时间
|
||||
'pay_end_time' => strtotime(input('pay_end_time', '')),//尾款支付时间
|
||||
'presale_num' => input('presale_num', ''),//限购
|
||||
'deliver_type' => input('deliver_type', ''),//发货方式
|
||||
'deliver_time' => input('deliver_time', ''),//发货时间
|
||||
'is_fenxiao' => input('is_fenxiao', ''),//是否参与分销
|
||||
'is_deposit_back' => input('is_deposit_back', ''),//是否支持退定金
|
||||
'deposit_agreement' => input('deposit_agreement', ''),//退定金协议
|
||||
'remark' => input('remark', ''),//活动规则说明
|
||||
];
|
||||
if ($common_data[ 'deliver_type' ] == 0) {
|
||||
$common_data[ 'deliver_time' ] = strtotime($common_data[ 'deliver_time' ]);
|
||||
}
|
||||
if ($common_data[ 'is_deposit_back' ] == 0) {
|
||||
$common_data[ 'deposit_agreement' ] = '';
|
||||
}
|
||||
|
||||
$sku_list = input('sku_list', '');
|
||||
$goods = [
|
||||
'goods_id' => input('goods_id', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
];
|
||||
return $presale_model->editPresale($common_data, $goods, $sku_list);
|
||||
|
||||
} else {
|
||||
|
||||
//获取预售信息
|
||||
$presale_info = $presale_model->getPresaleDetail($presale_id, $this->site_id)[ 'data' ] ?? [];
|
||||
if (empty($presale_info)) $this->error('未获取到活动数据', href_url('presale://shop/presale/lists'));
|
||||
$this->assign('presale_info', $presale_info);
|
||||
return $this->fetch("presale/edit");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 预售详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$presale_model = new PresaleModel();
|
||||
$presale_id = input('presale_id', '');
|
||||
$presale_info = $presale_model->getPresaleJoinGoodsList($presale_id, $this->site_id)[ 'data' ] ?? [];
|
||||
if (empty($presale_info)) $this->error('未获取到活动数据', href_url('presale://shop/presale/lists'));
|
||||
$this->assign('info', $presale_info);
|
||||
return $this->fetch("presale/detail");
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除预售活动
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$presale_id = input('presale_id', '');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
return $presale_model->deletePresale($presale_id, $site_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 结束预售活动
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
$presale_id = input('presale_id', '');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
return $presale_model->finishPresale($presale_id, $site_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @return array
|
||||
*/
|
||||
public function getSkuList()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$presale_model = new PresaleModel();
|
||||
$presale_id = input('presale_id', '');
|
||||
$presale_info = $presale_model->getPresaleGoodsList($presale_id, $this->site_id);
|
||||
return $presale_info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预售推广
|
||||
*/
|
||||
public function presaleUrl()
|
||||
{
|
||||
$presale_id = input('presale_id', '');
|
||||
$app_type = input('app_type', 'all');
|
||||
|
||||
$presale_model = new PresaleModel();
|
||||
$res = $presale_model->urlQrcode('/pages_promotion/presale/detail', [ 'id' => $presale_id ], 'presale', $app_type, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除预售活动
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$presale_id = input('presale_id', '');
|
||||
$presale_model = new PresaleModel();
|
||||
foreach ($presale_id as $k => $v){
|
||||
$res = $presale_model->deletePresale($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束预售活动
|
||||
*/
|
||||
public function finishAll()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$presale_id = input('presale_id', '');
|
||||
$presale_model = new PresaleModel();
|
||||
foreach ($presale_id as $k => $v){
|
||||
$res = $presale_model->finishPresale($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
174
addon/presale/shop/controller/Refund.php
Executable file
174
addon/presale/shop/controller/Refund.php
Executable file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\presale\shop\controller;
|
||||
|
||||
use addon\presale\model\PresaleOrder;
|
||||
use addon\presale\model\PresaleOrderRefund;
|
||||
use app\shop\controller\BaseShop;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 退款订单
|
||||
*/
|
||||
class Refund extends BaseShop
|
||||
{
|
||||
/*
|
||||
* 订单列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$presale_order_model = new PresaleOrder();
|
||||
|
||||
$condition = [
|
||||
[ 'ppo.site_id', '=', $this->site_id ],
|
||||
];
|
||||
//获取续签信息
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
//搜索类型
|
||||
$order_label = input('order_label', 'order_no');
|
||||
$search = input('search', '');
|
||||
if ($search) {
|
||||
$condition[] = [ 'ppo.' . $order_label, 'like', '%' . $search . '%' ];
|
||||
}
|
||||
//退款状态
|
||||
$refund_status = input('refund_status', '');
|
||||
if ($refund_status !== '') {
|
||||
$condition[] = [ 'ppo.refund_status', '=', $refund_status ];
|
||||
} else {
|
||||
$condition[] = [ 'ppo.refund_status', '<>', 0 ];
|
||||
}
|
||||
//订单来源
|
||||
$order_from = input("order_from", '');
|
||||
if ($order_from != "") {
|
||||
$condition[] = [ "ppo.order_from", "=", $order_from ];
|
||||
}
|
||||
//定金支付方式
|
||||
$deposit_pay_type = input("deposit_pay_type", '');
|
||||
if ($deposit_pay_type) {
|
||||
$condition[] = [ "ppo.deposit_pay_type", "=", $deposit_pay_type ];
|
||||
}
|
||||
//尾款支付方式
|
||||
$final_pay_type = input("final_pay_type", '');
|
||||
if ($final_pay_type) {
|
||||
$condition[] = [ "ppo.final_pay_type", "=", $final_pay_type ];
|
||||
}
|
||||
//订单类型
|
||||
$order_type = input('order_type', '');
|
||||
if ($order_type && $order_type != 'all') {
|
||||
$condition[] = [ "ppo.order_type", "=", $order_type ];
|
||||
}
|
||||
//创建时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && $end_time) {
|
||||
$condition[] = [ 'ppo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'ppo.create_time', '<=', date_to_time($end_time) ];
|
||||
|
||||
} elseif ($start_time && !$end_time) {
|
||||
$condition[] = [ 'ppo.create_time', '>=', date_to_time($start_time) ];
|
||||
}
|
||||
$list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size, 'id desc');
|
||||
return $list;
|
||||
} else {
|
||||
//搜索方式
|
||||
$order_label_list = array (
|
||||
"deposit_refund_no" => "退款编号",
|
||||
"order_no" => "订单号",
|
||||
"goods_name" => "商品名称",
|
||||
"name" => "收货人姓名",
|
||||
"mobile" => "收货人手机号",
|
||||
);
|
||||
$this->assign('order_label_list', $order_label_list);
|
||||
//订单状态
|
||||
$order_model = new PresaleOrderRefund();
|
||||
$order_status_list = $order_model->order_refund_status;
|
||||
$this->assign("order_status_list", $order_status_list);
|
||||
|
||||
//订单来源 (支持端口)
|
||||
$order_from = Config::get("app_type");
|
||||
$this->assign('order_from_list', $order_from);
|
||||
|
||||
$order_common_model = new OrderCommonModel();
|
||||
$order_type_list = $order_common_model->getOrderTypeStatusList();
|
||||
$this->assign("order_type_list", $order_type_list);
|
||||
|
||||
$pay_type = $order_common_model->getPayType();
|
||||
$this->assign("pay_type_list", $pay_type);
|
||||
|
||||
|
||||
|
||||
return $this->fetch("refund/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$presale_order_model = new PresaleOrder();
|
||||
|
||||
$id = input('id', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'id', '=', $id ]
|
||||
];
|
||||
|
||||
$info = $presale_order_model->getPresaleOrderInfo($condition);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到订单数据', href_url('presale://shop/refund/lists'));
|
||||
$this->assign('detail', $info[ 'data' ]);
|
||||
|
||||
return $this->fetch('refund/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝退款
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
$presale_order_refund_model = new PresaleOrderRefund();
|
||||
|
||||
$data = [
|
||||
'id' => input('id', ''),
|
||||
'site_id' => $this->site_id,
|
||||
'refuse_reason' => input('refuse_reason', ''),
|
||||
];
|
||||
$res = $presale_order_refund_model->refuseRefund($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意退款
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
$presale_order_refund_model = new PresaleOrderRefund();
|
||||
|
||||
$data = [
|
||||
'id' => input('id', ''),
|
||||
'site_id' => $this->site_id,
|
||||
];
|
||||
|
||||
$res = $presale_order_refund_model->agreeRefund($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
305
addon/presale/shop/view/order/detail.html
Executable file
305
addon/presale/shop/view/order/detail.html
Executable file
@@ -0,0 +1,305 @@
|
||||
<link rel="stylesheet" href="SHOP_CSS/order_detail.css"/>
|
||||
<link rel="stylesheet" href="SHOP_CSS/package.css"/>
|
||||
|
||||
<div class="order-detail">
|
||||
<div class="layui-row layui-col-space1 order-detail-info" >
|
||||
<div class="layui-col-md4 order-detail-left" >
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header nav-title">订单信息</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单编号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$order_detail['order_no']}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$order_detail['order_type_name']}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单来源:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail.order_from_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">买家:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux"><a class="text-color" target="_blank" href='{:href_url("shop/member/editmember?member_id=".$order_detail["member_id"])}'>{$order_detail.name}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item order-detail-hr"></div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">定金支付方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['deposit_pay_type_name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">定金支付流水号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['deposit_out_trade_no']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">定金支付时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{:time_to_date($order_detail['pay_deposit_time'])}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if !empty($order_detail['final_pay_type'])}
|
||||
<div class="layui-form-item order-detail-hr"></div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">尾款支付方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['final_pay_type_name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">尾款支付流水号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['final_out_trade_no']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">尾款支付时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{:time_to_date($order_detail['pay_final_time'])}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="layui-form-item order-detail-hr"></div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">配送方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['delivery_type_name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收货人:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系电话:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['mobile']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收货地址:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['full_address']}-{$order_detail['address']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item order-detail-hr"></div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">买家留言:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
{if $order_detail['buyer_message'] == ""}
|
||||
<p>-</p>
|
||||
{else/}
|
||||
<p>{$order_detail['buyer_message']}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md8 order-detail-operation">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">订单状态:{$order_detail.order_status_name}</div>
|
||||
<div class="layui-card-body">
|
||||
<p class="order-detail-tips"></p>
|
||||
{php}
|
||||
$order_json_data = json_decode($order_detail['order_status_action'], true);
|
||||
$action = $order_json_data['action'];
|
||||
{/php}
|
||||
{foreach $action as $action_k => $action_item}
|
||||
<a class="layui-btn" href="javascript:orderAction('{$action_item.action}', '{$order_detail.id}')">{$action_item.title}</a>
|
||||
{/foreach}
|
||||
<br>
|
||||
<i class="layui-icon layui-icon-about"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="order-detail-dl">
|
||||
<dl>
|
||||
<dt>提醒:</dt>
|
||||
<dd>交易成功后,平台将把货款结算至你的店铺账户余额,你可申请提现;</dd>
|
||||
<dd>请及时关注你发出的包裹状态,确保能配送至买家手中;</dd>
|
||||
<dd>如果买家表示未收到货或者货物有问题,请及时联系买家积极处理,友好协商;</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if $order_detail['is_invoice'] == 1}
|
||||
<div style="height: 15px;"></div>
|
||||
<div class="layui-row form-wrap invoice-view">
|
||||
|
||||
<div class="layui-col-md6">
|
||||
<h4 class="invoice-title">发票信息</h4>
|
||||
<ul class="invoice-box">
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票类型:</label>
|
||||
<div class="invoice-content">{if $order_detail['invoice_type'] == 1}纸质{else/}电子{/if}{if $order_detail['is_tax_invoice'] == 1}专票{else/}普票{/if}</div>
|
||||
</li>
|
||||
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票抬头:</label>
|
||||
<div class="invoice-content">{$order_detail['invoice_title']}</div>
|
||||
</li>
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票抬头类型:</label>
|
||||
<div class="invoice-content">{$order_detail['invoice_title_type'] == 1 ? '个人' : '企业'}</div>
|
||||
</li>
|
||||
{if $order_detail['invoice_title_type'] == 2}
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">纳税人识别号:</label>
|
||||
<div class="invoice-content">{$order_detail['taxpayer_number']}</div>
|
||||
</li>
|
||||
{/if}
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票内容:</label>
|
||||
<div class="invoice-content">{$order_detail['invoice_content']}</div>
|
||||
</li>
|
||||
|
||||
{if $order_detail['invoice_type'] == 1}
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票邮寄地址:</label>
|
||||
<div class="invoice-content">{$order_detail['invoice_full_address']}</div>
|
||||
</li>
|
||||
{else/}
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票接收邮件:</label>
|
||||
<div class="invoice-content">{$order_detail['invoice_email']}</div>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<h4 class="invoice-title">发票费用</h4>
|
||||
<ul class="invoice-box">
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票费用:</label>
|
||||
<div class="invoice-content"><span class="invoice-money">¥{$order_detail.invoice_money}</span> </div>
|
||||
</li>
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票税率:</label>
|
||||
<div class="invoice-content"><span class="invoice-money">{$order_detail.invoice_rate}%</span> </div>
|
||||
</li>
|
||||
<li class="invoice-item">
|
||||
<label class="invoice-label">发票邮寄费用:</label>
|
||||
<div class="invoice-content"><span class="invoice-money">¥{$order_detail.invoice_delivery_money}</span> </div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div style="height: 15px;"></div>
|
||||
|
||||
<div class="order-detail-table">
|
||||
<table class="layui-table" lay-filter="parse-table-order-product" lay-skin="line" lay-size="lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th lay-data="{field:'product_name', width:200}">商品</th>
|
||||
<th lay-data="{field:'sale_num'}">数量</th>
|
||||
<th lay-data="{field:'price'}">单价</th>
|
||||
<th lay-data="{field:'total_money'}">总价</th>
|
||||
<th lay-data="{field:'presale_deposit'}">预售定金单价</th>
|
||||
<th lay-data="{field:'presale_deposit_money'}">定金总额</th>
|
||||
<th lay-data="{field:'presale_price'}">抵扣金额单价</th>
|
||||
<th lay-data="{field:'presale_money'}">抵扣总额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{$order_detail.sku_name}</td>
|
||||
<td>{$order_detail.num}</td>
|
||||
<td>{$order_detail.price}</td>
|
||||
<td>{$order_detail.goods_money}</td>
|
||||
<td>{$order_detail.presale_deposit}</td>
|
||||
<td>{$order_detail.presale_deposit_money}</td>
|
||||
<td>{$order_detail.presale_price}</td>
|
||||
<td>{$order_detail.presale_money}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="layui-row order-detail-total">
|
||||
<div class="layui-col-md9"> </div>
|
||||
<div class="layui-col-md3 order-money-box" >
|
||||
<div>商品总额:¥{$order_detail["goods_money"]}</div>
|
||||
<div>店铺优惠券:¥{$order_detail["coupon_money"]}</div>
|
||||
<div>配送费用:¥{$order_detail["delivery_money"]}</div>
|
||||
<div>发票费用:¥{$order_detail["invoice_money"]}</div>
|
||||
<div>发票邮寄费用:¥{$order_detail["invoice_delivery_money"]}</div>
|
||||
<div>定金总额:¥{$order_detail["presale_deposit_money"]}</div>
|
||||
<div>抵扣总额:¥{$order_detail["presale_money"]}</div>
|
||||
<div>尾款总额:¥{$order_detail["final_money"]}</div>
|
||||
<div>订单共{$order_detail["num"]}件商品,总计:<span>¥{$order_detail["order_money"]}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="order/order_common_action" /}
|
||||
368
addon/presale/shop/view/order/lists.html
Executable file
368
addon/presale/shop/view/order/lists.html
Executable file
@@ -0,0 +1,368 @@
|
||||
<style type="text/css">
|
||||
.address{height: 0;width: 1px; border: none; overflow: hidden;}
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
.layui-layout-admin .screen{margin-top: 15px;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
</style>
|
||||
|
||||
<div class="layui-collapse tips-wrap">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">操作提示</h2>
|
||||
<ul class="layui-colla-content layui-show">
|
||||
<li>商品预售展示商品预售相关信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">搜索方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="order_label" >
|
||||
{foreach $order_label_list as $k => $label_val}
|
||||
<option value="{$k}">{$label_val}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="search" autocomplete="off" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">下单时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(7, this);return false;">近7天</button>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(30, this);return false;">近30天</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">订单类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="order_type" lay-filter="order_type">
|
||||
{foreach $order_type_list as $order_type_k => $order_type_val}
|
||||
<option value="{$order_type_val.type}">{$order_type_val.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">订单来源:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="order_from">
|
||||
<option value="">全部</option>
|
||||
{foreach $order_from_list as $order_from_k => $order_from_v}
|
||||
<option value="{$order_from_k}">{$order_from_v['name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">定金付款方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="deposit_pay_type" >
|
||||
<option value="">全部</option>
|
||||
{foreach pay_type_list as $pay_type_k => $pay_type_v}
|
||||
<option value="{$pay_type_k}">{$pay_type_v}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">尾款付款方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="final_pay_type" >
|
||||
<option value="">全部</option>
|
||||
{foreach pay_type_list as $pay_type_k => $pay_type_v}
|
||||
<option value="{$pay_type_k}">{$pay_type_v}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="presale_tab">
|
||||
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="">全部</li>
|
||||
{foreach $order_status_list as $status_val}
|
||||
<li data-status="{$status_val.status}">{$status_val.name}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="presale_list" lay-filter="presale_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
{include file="order/order_common_action" /}
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.sku_image){ }}
|
||||
<img layer-src="{{ns.img(d.sku_image.split(',')[0],'big')}}" src="{{ns.img(d.sku_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{{d.sku_name}}">{{d.sku_name}}</a>
|
||||
<a href="javascript:;" class="multi-line-hiding" title="">¥{{ d.price }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 金额 -->
|
||||
<script id="price" type="text/html">
|
||||
<div class="layui-elip">定金:¥{{ d.presale_deposit_money }}</div>
|
||||
<div class="layui-elip">尾款:¥{{ d.final_money }}</div>
|
||||
</script>
|
||||
|
||||
<!-- 收货人地址 -->
|
||||
<script id="addressHtml" type="text/html">
|
||||
<div class="layui-elip">{{ d.name }}</div>
|
||||
<div class="layui-elip">{{ d.mobile }}</div>
|
||||
{{# if(d.full_address){ }}
|
||||
<div class="layui-elip" title="{{ d.full_address }} {{ d.address }}" > <input type="text" class="address" id="address" value="{{ d.full_address }} {{ d.address }}"><a href="javascript:ns.copy('address');" class="iconfont iconfuzhi" style="margin-top: 4px"></a> {{ d.full_address }} {{ d.address }}</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
{{# if(d.is_deposit_back!=1 && d.can_refund !=1){ }}
|
||||
{{# layui.each(d.action, function(index, item){ }}
|
||||
<a class="layui-btn" href="javascript:orderAction('{{item.action}}', '{{d.id}}')">{{item.title}}</a>
|
||||
{{# }); }}
|
||||
{{# } }}
|
||||
{{# if(d.order_status == 1 && d.is_deposit_back==1 && d.can_refund ==1){ }}
|
||||
<a class="layui-btn" lay-event="agree">退定金</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var laytpl,table,form,laydate,element,repeat_flag;
|
||||
layui.use(['form', 'element','laydate','laytpl'], function() {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
laydate = layui.laydate;
|
||||
element = layui.element;
|
||||
repeat_flag = false; //防重复标识
|
||||
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
element.on('tab(presale_tab)', function() {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'order_status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#presale_list',
|
||||
url: ns.url("presale://shop/order/lists"),
|
||||
where:{
|
||||
'presale_id':{$presale_id}
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
field: 'order_no',
|
||||
title: '订单编号',
|
||||
unresize: 'false',
|
||||
width:'10%'
|
||||
},{
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
templet:'#goods',
|
||||
width:'20%'
|
||||
}, {
|
||||
field:'num',
|
||||
title: '购买数量',
|
||||
unresize: 'false',
|
||||
templet:function(data){
|
||||
return data.num + '件';
|
||||
},
|
||||
width:'6%'
|
||||
}, {
|
||||
title: '金额',
|
||||
unresize: 'false',
|
||||
templet:'#price',
|
||||
width:'10%'
|
||||
},{
|
||||
field:'nickname',
|
||||
title: '购买人',
|
||||
unresize: 'false',
|
||||
width:'10%'
|
||||
}, {
|
||||
title: '收货人信息',
|
||||
unresize: 'false',
|
||||
templet:'#addressHtml',
|
||||
width:'10%'
|
||||
}, {
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width:'10%',
|
||||
templet:function(data){
|
||||
if(data.order_status==1 && data.is_deposit_back==1 && data.can_refund==1){
|
||||
return '已关闭(未支付尾款)'
|
||||
}else{
|
||||
var html = data.order_status_name;
|
||||
if(data.refund_status != 0){
|
||||
html += '('+ data.refund_status_name +')';
|
||||
}
|
||||
return html;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '创建时间',
|
||||
unresize: 'false',
|
||||
templet:function(data){
|
||||
return ns.time_to_date(data.create_time);
|
||||
},
|
||||
width:"10%"
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //查看
|
||||
window.open(ns.href("presale://shop/order/detail", {"id": data.id}));
|
||||
break;
|
||||
case 'agree': //同意
|
||||
agreeRefund(data.id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//同意退款
|
||||
function agreeRefund(id){
|
||||
layer.confirm('确定该退定金吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/refund/agree"),
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 七天时间
|
||||
*/
|
||||
function datePick(date_num,event_obj){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
$(event_obj).addClass('selected');
|
||||
// alert(new Date().format("yyyy-MM-dd hh:mm"));
|
||||
|
||||
Date.prototype.Format = function (fmt,date_num) { //author: meizz
|
||||
this.setDate(this.getDate()-date_num);
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"H+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
||||
|
||||
// var now_time = new Date().Format("yyyy-MM-dd HH:mm:ss",0);//当前日期
|
||||
var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
|
||||
var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
|
||||
$("input[name=start_time]").val(before_time,0);
|
||||
$("input[name=end_time]").val(now_time,date_num-1);
|
||||
}
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("presale://shop/presale/add");
|
||||
}
|
||||
</script>
|
||||
116
addon/presale/shop/view/order/order_common_action.html
Executable file
116
addon/presale/shop/view/order/order_common_action.html
Executable file
@@ -0,0 +1,116 @@
|
||||
<script type="text/javascript">
|
||||
var laytpl;
|
||||
var form;
|
||||
//渲染模板引擎
|
||||
layui.use(['laytpl','form'], function(){
|
||||
laytpl = layui.laytpl;
|
||||
form = layui.form;
|
||||
form.render();
|
||||
});
|
||||
/**
|
||||
* 订单操作
|
||||
* @param fun
|
||||
* @param order_id
|
||||
*/
|
||||
function orderAction(fun, order_id){
|
||||
eval(fun+"("+order_id+")");
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
* @param order_id
|
||||
*/
|
||||
function orderClose(order_id){
|
||||
layer.confirm('确定要关闭该订单吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/order/close"),
|
||||
data: {order_id : order_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付定金
|
||||
* @param order_id
|
||||
*/
|
||||
function offlinePayDeposit(order_id){
|
||||
layer.confirm('确定要线下支付定金吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/order/offlinePayDeposit"),
|
||||
data: {order_id : order_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付尾款
|
||||
* @param order_id
|
||||
*/
|
||||
function offlinePayFinal(order_id){
|
||||
layer.confirm('确定要线下支付尾款吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/order/offlinePayFinal"),
|
||||
data: {order_id : order_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
* @param order_id
|
||||
*/
|
||||
function deleteOrder(order_id){
|
||||
layer.confirm('确定要删除该订单吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/order/deleteOrder"),
|
||||
data: {order_id : order_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
|
||||
if (res.code == 0) {
|
||||
location.hash = ns.hash("presale://shop/order/lists");
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
683
addon/presale/shop/view/presale/add.html
Executable file
683
addon/presale/shop/view/presale/add.html
Executable file
@@ -0,0 +1,683 @@
|
||||
<style>
|
||||
.len-input {width: 100%;max-width: 120px;}
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.form-wrap {position: relative;}
|
||||
.layui-carousel { position: absolute; top: 15px; left: 1325px; background: #fff;}
|
||||
.goods_num {padding-left: 20px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="presale_name" value="{$presale_name}" lay-verify="required" autocomplete="off" class="layui-input len-long" maxlength="40">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>定金支付时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="start_time" name="start_time" lay-verify="required" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="end_time" name="end_time" lay-verify="required|etime" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>尾款支付时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="pay_start_time" name="pay_start_time" lay-verify="required|spay_time" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="pay_end_time" name="pay_end_time" lay-verify="required|epay_time" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>注意:当尾款支付时间结束,那么该预售活动也就结束</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限购:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" min="0" name="presale_num" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>下单时每人最多可购买数量限制,不填时不限制。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">预计发货时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="deliver_type" value="0" lay-filter="deliver_type" checked="checked" title="固定时间">
|
||||
<input type="radio" name="deliver_type" value="1" lay-filter="deliver_type" title="支付尾款后">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item deliver-time end-time">
|
||||
<label class="layui-form-label">固定时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" lay-verify="deliver_time" id="deliver_time" class="layui-input len-mid" autocomplete="off" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item deliver-time fixed-term" style="display: none">
|
||||
<label class="layui-form-label">支付尾款:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="1" max="365" id="pay_days" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<span class="layui-form-mid">天后,开始发货</span>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>不能小于0,且必须为整数</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否参与分销:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_fenxiao" value="0" title="不参与" checked>
|
||||
<input type="radio" name="is_fenxiao" value="1" title="参与">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否支持退定金:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_deposit_back" value="0" title="是" lay-filter="deposit_back" checked>
|
||||
<input type="radio" name="is_deposit_back" value="1" title="否" lay-filter="deposit_back">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text deposit_agreement layui-hide">
|
||||
<label class="layui-form-label">定金退还协议:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="deposit_agreement" id="deposit_agreement" class="layui-textarea len-long" maxlength="150"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label">活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></table>
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button> <span class="goods_num">已选商品(<span id="goods_num" class="text-color">0</span>)</span>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="sku_ids">
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">活动规则说明:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="300"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPresaleList()">返回</button>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-carousel" >
|
||||
<img src="__STATIC__/img/presale.png" >
|
||||
</div>-->
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="presale-stock">预售库存</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="presale-deposit">定金</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="presale-price">定金抵扣金额</button>
|
||||
</script>
|
||||
<script>
|
||||
var goodsId = {}, selectedGoodsId = [], sku_list = [],
|
||||
form,laydate,repeat_flag,currentDate,minDate;
|
||||
layui.use(['form', 'laydate'], function() {
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
repeat_flag = false;
|
||||
currentDate = new Date();
|
||||
minDate = "";
|
||||
currentDate.setDate(currentDate.getDate() + 30);
|
||||
form.render();
|
||||
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
for (var i = 0; i <= 30; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
if (i == 1) {
|
||||
var html = '<option value="' + i + '" selected>0' + i + '</option>';
|
||||
}
|
||||
$(".presale-day").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 23; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
$(".presale-hour").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 59; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
$(".presale-minute").append(html);
|
||||
}
|
||||
form.render('select');
|
||||
|
||||
//定金开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
}
|
||||
});
|
||||
//定金结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(currentDate)
|
||||
});
|
||||
|
||||
var payDate = new Date(currentDate);
|
||||
payDate.setDate(payDate.getDate() + 1);
|
||||
|
||||
//尾款开始时间
|
||||
laydate.render({
|
||||
elem: '#pay_start_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: payDate
|
||||
});
|
||||
|
||||
payDate.setDate(payDate.getDate() + 29);
|
||||
|
||||
//尾款结束时间
|
||||
laydate.render({
|
||||
elem: '#pay_end_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: payDate
|
||||
});
|
||||
|
||||
//发货时间
|
||||
laydate.render({
|
||||
elem: '#deliver_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
// 监听单选按钮
|
||||
form.on('radio(deliver_type)', function(data) {
|
||||
if (data.value == 0) {
|
||||
$('#deliver_time').attr('lay-verify','deliver_time');
|
||||
$('#pay_days').attr('lay-verify','');
|
||||
$('.deliver-time.end-time').show();
|
||||
$('.deliver-time.fixed-term').hide();
|
||||
$('#pay_days').val('');
|
||||
} else {
|
||||
$('#deliver_time').attr('lay-verify','');
|
||||
$('#pay_days').attr('lay-verify','days');
|
||||
$('.deliver-time.end-time').hide();
|
||||
$('.deliver-time.fixed-term').show();
|
||||
$('#deliver_time').val('');
|
||||
}
|
||||
});
|
||||
|
||||
// 监听单选按钮是否退定金显示退定金协议
|
||||
form.on('radio(deposit_back)', function(data) {
|
||||
if (data.value == 1) {
|
||||
$(".deposit_agreement").removeClass("layui-hide");
|
||||
} else {
|
||||
$('#deposit_agreement').val('');
|
||||
$(".deposit_agreement").addClass("layui-hide");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
etime: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#deposit_start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
spay_time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time =(new Date(value)).getTime();
|
||||
var deposit_end_time = (new Date($("#end_time").val())).getTime();
|
||||
|
||||
if (now_time > start_time) {
|
||||
return '开始时间不能小于当前时间!'
|
||||
}
|
||||
|
||||
if(start_time < deposit_end_time){
|
||||
return '尾款开始支付时间不能小于定金结束支付时间!'
|
||||
}
|
||||
|
||||
},
|
||||
epay_time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#pay_start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
|
||||
if (now_time > start_time) {
|
||||
return '开始时间不能小于当前时间!'
|
||||
}
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
presale_stock: function(value) {
|
||||
if (value.trim() == "") {
|
||||
return '预售库存不能为空';
|
||||
}
|
||||
if (Number(value) <= 0) {
|
||||
return '预售库存必须大于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '砍价库存必须为整数';
|
||||
}
|
||||
},
|
||||
presale_deposit: function(value, item) {
|
||||
var sku_id = $(item).attr('data-id');
|
||||
var price = $(item).parent().parent().siblings().children().children().children(".presale-price-" + sku_id).text();
|
||||
if (Number(value) <= 0) {
|
||||
return '定金必须大于0';
|
||||
}
|
||||
if (Number(value) === Number(price)) {
|
||||
return '定金不能等于价格';
|
||||
}
|
||||
if (Number(value) > Number(price)) {
|
||||
return '定金不能大于价格';
|
||||
}
|
||||
},
|
||||
presale_price: function(value, item) {
|
||||
var sku_id = $(item).attr('data-id');
|
||||
var presale_deposit = $(item).parent().parent().siblings().children().children(".presale_deposit_" + sku_id).val();
|
||||
var price = $(item).parent().parent().siblings().children().children().children(".presale-price-" + sku_id).text();
|
||||
if (value.trim() == "") {
|
||||
return '定金可抵金额不能为空';
|
||||
}
|
||||
if (Number(value) === Number(price)) {
|
||||
return '定金可抵金额不能等于价格';
|
||||
}
|
||||
if (Number(value) > Number(price)) {
|
||||
return '定金可抵金额不能大于价格';
|
||||
}
|
||||
if (Number(value) < Number(presale_deposit)) {
|
||||
return '定金可抵金额不能小于定金';
|
||||
}
|
||||
},
|
||||
deliver_time: function(value) {
|
||||
var pay_end_time = (new Date($("#pay_end_time").val())).getTime();
|
||||
var deliver_time = (new Date(value)).getTime();
|
||||
if (value.trim() == "") {
|
||||
return '预计发货时间不能为空!';
|
||||
}
|
||||
if(deliver_time < pay_end_time && deliver_time!=''){
|
||||
return '预计发货时间不能小于尾款结束支付时间!'
|
||||
}
|
||||
|
||||
},
|
||||
days: function(value) {
|
||||
if (value.trim() == "") {
|
||||
return '预计发货时间不能为空!';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
var field = data.field;
|
||||
|
||||
if (!Object.keys(goodsId).length) {
|
||||
layer.msg("请选择活动商品!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
var deposit_end_time = (new Date($("#end_time").val())).getTime();
|
||||
var pay_start_time = (new Date($("#pay_start_time").val())).getTime();
|
||||
if(pay_start_time < deposit_end_time){
|
||||
layer.msg('尾款开始支付时间不能小于定金结束支付时间');
|
||||
$("#pay_start_time").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if(field.deliver_type == 1){
|
||||
field.deliver_time = $('#pay_days').val();
|
||||
}else{
|
||||
var pay_end_time = (new Date($("#pay_end_time").val())).getTime();
|
||||
var deliver_time = (new Date($("#deliver_time").val())).getTime();
|
||||
if(deliver_time < pay_end_time){
|
||||
layer.msg('预计发货时间不能小于尾款结束支付时间');
|
||||
$("#deliver_time").focus();
|
||||
return;
|
||||
}
|
||||
field.deliver_time = $('#deliver_time').val();
|
||||
}
|
||||
|
||||
field.goods_ids = selectedGoodsId.split(',');
|
||||
|
||||
var skuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
Object.values(item.sku_id).forEach(function (skuItem,skuIndex) {
|
||||
skuId.push(skuItem.sku);
|
||||
});
|
||||
});
|
||||
field.sku_ids = skuId;
|
||||
var skuLisArr = [];
|
||||
|
||||
sku_list.forEach(function(item,index) {
|
||||
var sku_detail = {};
|
||||
sku_detail.sku_id = item.sku_id;
|
||||
sku_detail.goods_id = item.goods_id;
|
||||
sku_detail.presale_stock = item.presale_stock || 0;
|
||||
sku_detail.presale_deposit = item.presale_deposit || 0.00;
|
||||
sku_detail.presale_price = item.presale_price || 0.00;
|
||||
skuLisArr.push(sku_detail);
|
||||
});
|
||||
field.sku_list = skuLisArr;
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("presale://shop/presale/add"),
|
||||
data: field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title: '操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function (index, layero) {
|
||||
location.hash = ns.hash("presale://shop/presale/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},{
|
||||
title: '商品名称',
|
||||
width: '23%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span class="presale-price presale-price-'+data.sku_id+'">' + data.price +'</span></p>';
|
||||
}
|
||||
}, {
|
||||
title: '预售库存',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#presaleStock'
|
||||
}, {
|
||||
title: '定金',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#presaleDeposit'
|
||||
}, {
|
||||
title: '定金可抵金额',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#presalePrice'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*/
|
||||
table.toolbar(function(obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "presale-stock":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "presale-deposit":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
case "presale-price":
|
||||
editInput(2,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '预售库存',
|
||||
value: 'presale_stock'
|
||||
},{
|
||||
name: '定金',
|
||||
value: 'presale_deposit'
|
||||
},{
|
||||
name: '定金抵扣金额',
|
||||
value: 'presale_price'
|
||||
}];
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="presale_edit_input" lay-verify="required" autocomplete="off" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='presale_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
*/
|
||||
function addGoods(){
|
||||
goodsSelect(function (data) {
|
||||
|
||||
sku_list = [];
|
||||
goodsId = [];
|
||||
|
||||
for (var key in data) {
|
||||
|
||||
goodsId['goods_'+ data[key].goods_id] = {};
|
||||
goodsId['goods_'+ data[key].goods_id].sku_id = {};
|
||||
goodsId['goods_'+ data[key].goods_id].spu_id = data[key].goods_id;
|
||||
|
||||
for (var sku in data[key].sku_list) {
|
||||
var item = data[key].sku_list[sku];
|
||||
|
||||
goodsId['goods_'+ data[key].goods_id].sku_id['sku_'+item.sku_id]={};
|
||||
goodsId['goods_'+ data[key].goods_id].sku_id['sku_'+item.sku_id].sku = item.sku_id;
|
||||
sku_list.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
renderTable(sku_list);
|
||||
$("input[name='sku_ids']").val(JSON.stringify(goodsId));
|
||||
|
||||
var spuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
spuId.push(item.spu_id);
|
||||
});
|
||||
$("#goods_num").html(sku_list.length);
|
||||
selectedGoodsId = spuId.toString();
|
||||
}, selectedGoodsId);
|
||||
|
||||
}
|
||||
|
||||
function delRow(obj,id) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == parseInt(id)){
|
||||
sku_list.splice(i,1);
|
||||
}
|
||||
}
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
delete item.sku_id['sku_'+id];
|
||||
if (!Object.keys(item.sku_id).length){
|
||||
delete goodsId['goods_'+item.spu_id];
|
||||
}
|
||||
});
|
||||
|
||||
var spuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
spuId.push(item.spu_id);
|
||||
});
|
||||
$("#goods_num").html(sku_list.length);
|
||||
selectedGoodsId = spuId.toString();
|
||||
$(obj).parents("tr").remove();
|
||||
}
|
||||
|
||||
function presaleStock(index,event) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index)
|
||||
sku_list[i].presale_stock = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
|
||||
function presaleDeposit(index,event) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index)
|
||||
sku_list[i].presale_deposit = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
|
||||
function presalePrice(index,event) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index)
|
||||
sku_list[i].presale_price = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
function deposit(sku_id,value,index,event){
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index)
|
||||
sku_list[i].presale_price = event.srcElement.value;
|
||||
}
|
||||
$(".presale_price_"+sku_id).val(value);
|
||||
//sku_list[index-1].presale_price = event.srcElement.value;
|
||||
}
|
||||
|
||||
function backPresaleList() {
|
||||
location.hash = ns.hash("presale://shop/presale/lists");
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="presaleStock">
|
||||
<input type="number" class="layui-input len-input presale-stock" value="{{d.presale_stock ? d.presale_stock : '0' }}" lay-verify="presale_stock" min="0" oninput="presaleStock({{ d.sku_id }},event)" onporpertychange="presaleStock({{ d.sku_id }},event)"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="presaleDeposit">
|
||||
<input type="number" class="layui-input len-input presale-deposit presale_deposit_{{ d.sku_id }}" value="{{d.presale_deposit ? d.presale_deposit : '0'}}" lay-verify="presale_deposit" min="0.00" oninput="presaleDeposit({{ d.sku_id }},event)" onporpertychange="presaleDeposit({{ d.sku_id }},event)" data-id="{{ d.sku_id }}" onchange="deposit({{ d.sku_id }},value,{{ d.sku_id }},event)"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="presalePrice">
|
||||
<input type="number" class="layui-input len-input presale-price presale_price_{{ d.sku_id }}" lay-verify="presale_price" min="0.00" value="{{d.presale_price ? d.presale_price : '0'}}" oninput="presalePrice({{ d.sku_id }},event)" onporpertychange="presalePrice({{ d.sku_id }},event)" data-id="{{ d.sku_id }}" />
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delRow(this,{{d.sku_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
127
addon/presale/shop/view/presale/detail.html
Executable file
127
addon/presale/shop/view/presale/detail.html
Executable file
@@ -0,0 +1,127 @@
|
||||
<link rel="stylesheet" href="STATIC_CSS/promotion_detail.css">
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item">
|
||||
<label>活动名称:</label>
|
||||
<span>{$info.presale_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>活动状态:</label>
|
||||
<span>{$info.status_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>添加时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.create_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.end_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>预售总库存:</label>
|
||||
<span>{$info.presale_stock}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>尾款支付开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.pay_start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>尾款支付结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.pay_end_time)}</span>
|
||||
</div>
|
||||
|
||||
<div class="promotion-view-item">
|
||||
<label>发货时间:</label>
|
||||
<span>
|
||||
{if $info.deliver_type == 0}
|
||||
{:date('Y-m-d H:i:s',$info.deliver_time)}
|
||||
{else/}
|
||||
支付尾款{$info.deliver_time}天后,开始发货
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>销量:</label>
|
||||
<span>{$info.sale_num}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否参与分销:</label>
|
||||
<span>{if $info.is_fenxiao == 1} 参与 {else/} 不参与 {/if}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否支持退定金:</label>
|
||||
<span>{if $info.is_deposit_back == 1} 否 {else/} 是 {/if}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">活动商品</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class='promotion-view-list'>
|
||||
<table id="promotion_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type='text/html' id="promotion_list_item_box_html">
|
||||
<div class="promotion-list-item-title">
|
||||
<div class="promotion-list-item-title-icon">
|
||||
<img src="{{ ns.img(d.sku_image) }}" alt="">
|
||||
</div>
|
||||
<p class="promotion-list-item-title-name multi-line-hiding">{{ d.sku_name }}</p>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var promotion_list = {:json_encode($info.sku_list, JSON_UNESCAPED_UNICODE)};
|
||||
layui.use('table', function() {
|
||||
new Table({
|
||||
elem: '#promotion_list',
|
||||
cols: [
|
||||
[{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '30%',
|
||||
unresize: 'false',
|
||||
templet: '#promotion_list_item_box_html'
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'presale_stock',
|
||||
title: '预售库存',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
field: 'presale_deposit',
|
||||
title: '定金',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return '¥' + data.presale_deposit;
|
||||
}
|
||||
}, {
|
||||
field: 'presale_price',
|
||||
title: '定金抵扣金额',
|
||||
unresize: 'false'
|
||||
}]
|
||||
],
|
||||
data: promotion_list
|
||||
});
|
||||
});
|
||||
</script>
|
||||
672
addon/presale/shop/view/presale/edit.html
Executable file
672
addon/presale/shop/view/presale/edit.html
Executable file
@@ -0,0 +1,672 @@
|
||||
<style>
|
||||
.len-input{width: 100%;max-width: 120px;}
|
||||
.layui-table-view{margin-top: 0;}
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.forbidden{cursor:not-allowed;background-color: #eee;}
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.form-wrap {position: relative;}
|
||||
.layui-carousel { position: absolute; top: 15px; left: 1325px; background: #fff;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="presale_name" lay-verify="required" value="{$presale_info.presale_name}" autocomplete="off" class="layui-input len-long" maxlength="40">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>定金支付时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="start_time" name="start_time" value="{:date('Y-m-d H:i:s', $presale_info.start_time)}" lay-verify="required|stime" class="layui-input" autocomplete="off" readonly>
|
||||
<input type="hidden" value="{:date('Y-m-d H:i:s', $presale_info.start_time)}" id="ystart_time" name="ystart_time">
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="end_time" name="end_time" value="{:date('Y-m-d H:i:s', $presale_info.end_time)}" lay-verify="required|etime" class="layui-input" autocomplete="off" readonly>
|
||||
<input type="hidden" value="{$presale_info.end_time}" id="old_end_time">
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>定金支付时间</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>尾款支付时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="pay_start_time" name="pay_start_time" value="{:date('Y-m-d H:i:s', $presale_info.pay_start_time)}" lay-verify="required|spay_time" class="layui-input" autocomplete="off" readonly>
|
||||
<input type="hidden" value="{:date('Y-m-d H:i:s', $presale_info.pay_start_time)}" id="pstart_time" name="pstart_time">
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="pay_end_time" name="pay_end_time" value="{:date('Y-m-d H:i:s', $presale_info.pay_end_time)}" lay-verify="required|epay_time" class="layui-input" autocomplete="off" readonly>
|
||||
<input type="hidden" value="{$presale_info.pay_end_time}" id="old_pay_end_time">
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限购:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" min="0" name="presale_num" value="{$presale_info.presale_num}" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>下单时每人最多可购买数量限制,不填时不限制。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">预计发货时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="deliver_type" value="0" lay-filter="filter" {if $presale_info.deliver_type == 0} checked {/if} title="固定时间">
|
||||
<input type="radio" name="deliver_type" value="1" lay-filter="filter" {if $presale_info.deliver_type == 1} checked {/if} title="支付尾款后">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item deliver-time end-time">
|
||||
<label class="layui-form-label">固定时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" lay-verify="deliver_time" id="deliver_time" {if $presale_info.deliver_type == 0} value="{:date('Y-m-d H:i:s',$presale_info.deliver_time)}" {/if} class="layui-input len-mid" autocomplete="off" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item deliver-time fixed-term">
|
||||
<label class="layui-form-label">支付尾款:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="1" max="365" id="pay_days" {if $presale_info.deliver_type == 1} value="{$presale_info.deliver_time}" {/if} lay-verify="days" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<span class="layui-form-mid">天后,开始发货</span>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>不能小于0,且必须为整数</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否参与分销:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_fenxiao" value="0" title="不参与" {if $presale_info.is_fenxiao == 0} checked {/if}>
|
||||
<input type="radio" name="is_fenxiao" value="1" title="参与" {if $presale_info.is_fenxiao == 1} checked {/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否支持退定金:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_deposit_back" lay-filter="deposit_back" value="0" title="是" {if $presale_info.is_deposit_back == 0} checked {/if}>
|
||||
<input type="radio" name="is_deposit_back" lay-filter="deposit_back" value="1" title="否" {if $presale_info.is_deposit_back == 1} checked {/if}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text deposit_agreement {if $presale_info.is_deposit_back == 0} layui-hide {/if}">
|
||||
<label class="layui-form-label">定金退还协议:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="deposit_agreement" class="layui-textarea len-long" maxlength="150">{$presale_info.deposit_agreement}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label">活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">活动规则说明:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="300">{$presale_info.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-carousel" >
|
||||
<img src="__STATIC__/img/presale.png" >
|
||||
</div>-->
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPresaleList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="presale_id" value="{$presale_info.presale_id}" />
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="presale-stock">预售库存</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="presale-deposit">定金</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="presale-price">定金抵扣金额</button>
|
||||
</script>
|
||||
<script>
|
||||
var deliver_type = $("input[name='deliver_type']:checked").val();
|
||||
if (deliver_type == 0) {
|
||||
$('#deliver_time').attr('lay-verify','deliver_time');
|
||||
$('#pay_days').attr('lay-verify','');
|
||||
$('.deliver-time.end-time').show();
|
||||
$('.deliver-time.fixed-term').hide();
|
||||
$('#pay_days').val('');
|
||||
} else {
|
||||
$('#deliver_time').attr('lay-verify','');
|
||||
$('#pay_days').attr('lay-verify','days');
|
||||
$('.deliver-time.end-time').hide();
|
||||
$('.deliver-time.fixed-term').show();
|
||||
$('#deliver_time').val('');
|
||||
}
|
||||
|
||||
var sku_list = [];
|
||||
sku_list = {:json_encode($presale_info.sku_list, JSON_UNESCAPED_UNICODE)};
|
||||
|
||||
sku_list.forEach(function (item,index) {
|
||||
item.is_delete = item.presale_stock ? 1 : 2;
|
||||
});
|
||||
|
||||
layui.use(['form', 'laydate'], function() {
|
||||
var form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false,
|
||||
startDate = '{$presale_info.start_time}',
|
||||
endDate = '{$presale_info.end_time}',
|
||||
minDate = "";
|
||||
form.render();
|
||||
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
//定金开始时间
|
||||
var now_time = (new Date()).getTime();
|
||||
|
||||
var ystart_time = (new Date($("#ystart_time").val())).getTime();
|
||||
if (now_time <= ystart_time) {
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//定金结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
}
|
||||
|
||||
var pstart_time = (new Date($("#pstart_time").val())).getTime();
|
||||
if(now_time <= pstart_time) {
|
||||
//尾款开始时间
|
||||
laydate.render({
|
||||
elem: '#pay_start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//尾款结束时间
|
||||
laydate.render({
|
||||
elem: '#pay_end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
}
|
||||
//发货时间
|
||||
laydate.render({
|
||||
elem: '#deliver_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
// 监听单选按钮
|
||||
form.on('radio(filter)', function(data) {
|
||||
if (data.value == 0) {
|
||||
$('#deliver_time').attr('lay-verify','deliver_time');
|
||||
$('#pay_days').attr('lay-verify','');
|
||||
$('.end-time').show();
|
||||
$('.fixed-term').hide();
|
||||
$('#pay_days').val('');
|
||||
} else {
|
||||
$('#deliver_time').attr('lay-verify','');
|
||||
$('#pay_days').attr('lay-verify','days');
|
||||
$('.end-time').hide();
|
||||
$('.fixed-term').show();
|
||||
$('#deliver_time').val('');
|
||||
}
|
||||
});
|
||||
|
||||
// 监听单选按钮是否退定金显示退定金协议
|
||||
form.on('radio(deposit_back)', function(data) {
|
||||
if (data.value == 1) {
|
||||
$(".deposit_agreement").removeClass("layui-hide");
|
||||
} else {
|
||||
$('#deposit_agreement').val('');
|
||||
$(".deposit_agreement").addClass("layui-hide");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
stime: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time =(new Date(value)).getTime();
|
||||
var ystart_time = (new Date($("#ystart_time").val())).getTime();
|
||||
if (now_time <= ystart_time) {
|
||||
if (now_time > start_time) {
|
||||
return '开始时间不能小于当前时间!'
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
etime: function(value) {
|
||||
var now_time = ((new Date()).getTime())/1000;
|
||||
var start_time = ((new Date($("#start_time").val())).getTime())/1000;
|
||||
var end_time = ((new Date(value)).getTime())/1000;
|
||||
var ystart_time = ((new Date($("#ystart_time").val())).getTime())/1000;
|
||||
var old_end_time = $("#old_end_time").val();
|
||||
|
||||
if (now_time <= ystart_time) {
|
||||
if (now_time > start_time) {
|
||||
return '开始时间不能小于当前时间!'
|
||||
}
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
if (end_time < old_end_time){
|
||||
return '结束时间不能小于之前设置的结束时间!';
|
||||
}
|
||||
}
|
||||
},
|
||||
spay_time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time =(new Date(value)).getTime();
|
||||
var deposit_end_time = (new Date($("#end_time").val())).getTime();
|
||||
|
||||
if (now_time > start_time) {
|
||||
return '开始时间不能小于当前时间!'
|
||||
}
|
||||
|
||||
if(start_time < deposit_end_time){
|
||||
return '尾款开始支付时间不能小于定金结束支付时间!'
|
||||
}
|
||||
|
||||
},
|
||||
epay_time: function(value) {
|
||||
var now_time = ((new Date()).getTime())/1000;
|
||||
var start_time = ((new Date($("#pay_start_time").val())).getTime())/1000;
|
||||
var end_time = ((new Date(value)).getTime())/1000;
|
||||
var old_pay_end_time = $("#old_pay_end_time").val();
|
||||
|
||||
if (now_time > start_time) {
|
||||
return '开始时间不能小于当前时间!'
|
||||
}
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
if (old_pay_end_time > end_time) {
|
||||
return '结束时间不能小于之前设置的结束时间!';
|
||||
}
|
||||
},
|
||||
deliver_time: function(value) {
|
||||
var pay_end_time = (new Date($("#pay_end_time").val())).getTime();
|
||||
var deliver_time = (new Date(value)).getTime();
|
||||
if (value.trim() == "") {
|
||||
return '预计发货时间不能为空!';
|
||||
}
|
||||
if(deliver_time < pay_end_time && deliver_time!=''){
|
||||
return '预计发货时间不能小于尾款结束支付时间!'
|
||||
}
|
||||
|
||||
},
|
||||
days: function(value) {
|
||||
|
||||
if (value.trim() == "") {
|
||||
return '预计发货时间不能为空!';
|
||||
}
|
||||
|
||||
},
|
||||
presale_stock: function(value) {
|
||||
|
||||
if (value.trim() == "") {
|
||||
return '预售库存不能为空';
|
||||
}
|
||||
if (Number(value) <= 0) {
|
||||
return '预售库存必须大于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '砍价库存必须为整数';
|
||||
}
|
||||
},
|
||||
presale_deposit: function(value, item) {
|
||||
var sku_id = $(item).attr('data-id');
|
||||
var price = $(item).parent().parent().siblings().children().children().children(".presale-price-" + sku_id).text();
|
||||
if (Number(value) <= 0) {
|
||||
return '定金必须大于0';
|
||||
}
|
||||
if (Number(value) === Number(price)) {
|
||||
return '定金不能等于价格';
|
||||
}
|
||||
if (Number(value) > Number(price)) {
|
||||
return '定金不能大于价格';
|
||||
}
|
||||
},
|
||||
presale_price: function(value, item) {
|
||||
var sku_id = $(item).attr('data-id');
|
||||
var presale_deposit = $(item).parent().parent().siblings().children().children(".presale_deposit_" + sku_id).val();
|
||||
var price = $(item).parent().parent().siblings().children().children().children(".presale-price-" + sku_id).text();
|
||||
if (value.trim() == "") {
|
||||
return '定金可抵金额不能为空';
|
||||
}
|
||||
if (Number(value) === Number(price)) {
|
||||
return '定金可抵金额不能等于价格';
|
||||
}
|
||||
if (Number(value) > Number(price)) {
|
||||
return '定金可抵金额不能大于价格';
|
||||
}
|
||||
if (Number(value) < Number(presale_deposit)) {
|
||||
return '定金可抵金额不能小于定金';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
var field = data.field;
|
||||
var deposit_end_time = (new Date($("#end_time").val())).getTime();
|
||||
var pay_start_time = (new Date($("#pay_start_time").val())).getTime();
|
||||
if(pay_start_time < deposit_end_time){
|
||||
layer.msg('尾款开始支付时间不能小于定金结束支付时间');
|
||||
$("#pay_start_time").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if(field.deliver_type == 1){
|
||||
field.deliver_time = $('#pay_days').val();
|
||||
}else{
|
||||
var pay_end_time = (new Date($("#pay_end_time").val())).getTime();
|
||||
var deliver_time = (new Date($("#deliver_time").val())).getTime();
|
||||
if(deliver_time < pay_end_time){
|
||||
layer.msg('预计发货时间不能小于尾款结束支付时间');
|
||||
$("#deliver_time").focus();
|
||||
return;
|
||||
}
|
||||
field.deliver_time = $('#deliver_time').val();
|
||||
}
|
||||
|
||||
field.sku_ids = [];
|
||||
field.goods_id = sku_list[0].goods_id;
|
||||
sku_list.forEach(function (item,index) {
|
||||
if (item.is_delete == 2) return false;
|
||||
field.sku_ids.push(item.sku_id);
|
||||
});
|
||||
|
||||
if (field.sku_ids.length == 0) {
|
||||
layer.msg("请选择参与活动商品!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
var skuLisArr = [];
|
||||
sku_list.forEach(function(item,index) {
|
||||
var sku_detail = {};
|
||||
sku_detail.sku_id = item.sku_id;
|
||||
sku_detail.goods_id = item.goods_id;
|
||||
sku_detail.presale_stock = item.presale_stock || 0;
|
||||
sku_detail.presale_deposit = item.presale_deposit || 0.00;
|
||||
sku_detail.presale_price = item.presale_price || 0.00;
|
||||
sku_detail.is_delete = item.is_delete || 1;
|
||||
skuLisArr.push(sku_detail);
|
||||
});
|
||||
field.sku_list = skuLisArr;
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("presale://shop/presale/edit"),
|
||||
data: field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("presale://shop/presale/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},{
|
||||
title: '商品名称',
|
||||
width: '23%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span class="presale-price presale-price-'+data.sku_id+'">' + data.price +'</span></p>';
|
||||
}
|
||||
}, {
|
||||
title: '预售库存',
|
||||
unresize: 'false',
|
||||
templet: '#presaleStock'
|
||||
}, {
|
||||
title: '定金',
|
||||
unresize: 'false',
|
||||
templet: '#presaleDeposit'
|
||||
}, {
|
||||
title: '定金抵扣金额',
|
||||
unresize: 'false',
|
||||
templet: '#presalePrice'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*/
|
||||
table.toolbar(function(obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "presale-stock":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "presale-deposit":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
case "presale-price":
|
||||
editInput(2,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '预售库存',
|
||||
value: 'presale_stock'
|
||||
},{
|
||||
name: '定金',
|
||||
value: 'presale_deposit'
|
||||
},{
|
||||
name: '定金抵扣金额',
|
||||
value: 'presale_price'
|
||||
}];
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="presale_edit_input" lay-verify="required" autocomplete="off" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='presale_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
sku_list[skuIndex].is_delete = 1;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function presaleStock(index,event) {
|
||||
sku_list[index-1].presale_stock = event.srcElement.value;
|
||||
}
|
||||
|
||||
function presaleDeposit(index,event) {
|
||||
sku_list[index-1].presale_deposit = event.srcElement.value;
|
||||
}
|
||||
|
||||
function presalePrice(index,event) {
|
||||
sku_list[index-1].presale_price = event.srcElement.value;
|
||||
}
|
||||
|
||||
function deposit(sku_id,value,index,event){
|
||||
$(".presale_price_"+sku_id).val(value);
|
||||
sku_list[index-1].presale_price = event.srcElement.value;
|
||||
}
|
||||
|
||||
function backPresaleList() {
|
||||
location.hash = ns.hash("presale://shop/presale/lists");
|
||||
}
|
||||
|
||||
$("body").off("click",".no-participation").on("click",".no-participation",function(){
|
||||
$(this).text("参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",true);
|
||||
$(item).attr("disabled",true);
|
||||
$(item).addClass("forbidden");
|
||||
$(item).attr("lay-verify","");
|
||||
});
|
||||
$(this).addClass("participation").removeClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_delete = 2;
|
||||
});
|
||||
|
||||
$("body").off("click",".participation").on("click",".participation",function(){
|
||||
$(this).text("不参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",false);
|
||||
$(item).attr("disabled",false);
|
||||
$(item).removeClass("forbidden");
|
||||
if($(item).hasClass("presale-stock")){
|
||||
$(item).attr("lay-verify","presale_stock");
|
||||
}else if($(item).hasClass("presale-deposit")){
|
||||
$(item).attr("lay-verify","presale_deposit");
|
||||
}else if($(item).hasClass("presale-price")){
|
||||
$(item).attr("lay-verify","presale_price");
|
||||
}
|
||||
});
|
||||
$(this).removeClass("participation").addClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_delete = 1;
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="presaleStock">
|
||||
{{# if(!d.presale_stock){ }}
|
||||
<input type="number" class="layui-input len-input presale-stock forbidden" value="{{d.presale_stock}}" min="0" oninput="presaleStock({{ d.LAY_INDEX }},event)" onporpertychange="presaleStock({{ d.LAY_INDEX }},event)" readonly disabled lay-verify=""/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input presale-stock" value="{{d.presale_stock}}" lay-verify="presale_stock" min="0" oninput="presaleStock({{ d.LAY_INDEX }},event)" onporpertychange="presaleStock({{ d.LAY_INDEX }},event)"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="presaleDeposit">
|
||||
{{# if(!d.presale_stock){ }}
|
||||
<input type="number" class="layui-input len-input presale-deposit forbidden presale_deposit_{{ d.sku_id }}" value="{{d.presale_deposit}}" min="0.00" oninput="presaleDeposit({{ d.LAY_INDEX }},event)" onporpertychange="presaleDeposit({{ d.LAY_INDEX }},event)" readonly disabled data-id="{{ d.sku_id }}" onchange="deposit({{ d.sku_id }},value,{{ d.LAY_INDEX }},event)" lay-verify=""/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input presale-deposit presale_deposit_{{ d.sku_id }}" value="{{d.presale_deposit}}" lay-verify="presale_deposit" min="0.00" oninput="presaleDeposit({{ d.LAY_INDEX }},event)" onporpertychange="presaleDeposit({{ d.LAY_INDEX }},event)" data-id="{{ d.sku_id }}" onchange="deposit({{ d.sku_id }},value,{{ d.LAY_INDEX }},event)"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="presalePrice">
|
||||
{{# if(!d.presale_stock){ }}
|
||||
<input type="number" class="layui-input len-input presale-price forbidden presale_price_{{ d.sku_id }}" value="{{d.presale_price}}" min="0.00" oninput="presalePrice({{ d.LAY_INDEX }},event)" onporpertychange="presalePrice({{ d.LAY_INDEX }},event)" readonly disabled data-id="{{ d.sku_id }}" lay-verify=""/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input presale-price presale_price_{{ d.sku_id }}" value="{{d.presale_price}}" lay-verify="presale_price" min="0.00" oninput="presalePrice({{ d.LAY_INDEX }},event)" onporpertychange="presalePrice({{ d.LAY_INDEX }},event)" data-id="{{ d.sku_id }}"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
{{# if(!d.presale_stock){ }}
|
||||
<a class="layui-btn participation">参与</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn no-participation">不参与</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
487
addon/presale/shop/view/presale/lists.html
Executable file
487
addon/presale/shop/view/presale/lists.html
Executable file
@@ -0,0 +1,487 @@
|
||||
<style>
|
||||
.screen{margin-bottom: 15px;}
|
||||
.contraction span{cursor: pointer;display: inline-block;width: 17px;height: 17px;text-align: center;line-height: 14px;user-select: none;}
|
||||
.sku-list{overflow: hidden;padding: 0 45px;}
|
||||
.sku-list li .img-wrap{vertical-align: middle;margin-right: 8px;width: 120px;height: 120px;text-align: center;line-height: 120px;}
|
||||
.sku-list li .img-wrap img{max-width: 100%;max-height: 100%;}
|
||||
.sku-list li .info-wrap span.sku-name{-webkit-line-clamp: 2;margin-bottom: 5px;}
|
||||
.sku-list li .info-wrap span{display: -webkit-box;margin-bottom: 5px;overflow: hidden;text-overflow: ellipsis;white-space: normal;word-break: break-all;-webkit-box-orient: vertical;-webkit-line-clamp: 1;}
|
||||
.sku-list li{float: left;display: flex;padding: 10px;margin-right: 10px;margin-bottom: 10px;border: 1px solid #EFEFEF;width: 294px;height: 280px;align-items: center;}
|
||||
.single-filter-box button{margin-bottom: 20px;}
|
||||
.layui-layout-admin .single-filter-box button{margin-bottom: 0;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
</style>
|
||||
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加预售</button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="goods_name" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">预售时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button type="button" class="layui-btn" lay-filter="search" lay-submit>筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="presale_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="">全部</li>
|
||||
{foreach $presale_status as $k=>$v}
|
||||
<li data-status="{$k}">{$v}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="presale_list" lay-filter="presale_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods_info">
|
||||
<div class="table-title">
|
||||
|
||||
<div class="contraction" data-id="{{d.presale_id}}" data-open="0">
|
||||
<span>+</span>
|
||||
</div>
|
||||
|
||||
<div class="title-pic">
|
||||
{{# if(d.goods_image){ }}
|
||||
<img layer-src="{{ns.img(d.goods_image.split(',')[0],'big')}}" src="{{ns.img(d.goods_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{{d.goods_name}}">{{d.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<!-- 时间 -->
|
||||
<script id="time" type="text/html">
|
||||
<div class="layui-elip">开始:{{ns.time_to_date(d.start_time)}}</div>
|
||||
<div class="layui-elip">结束:{{ns.time_to_date(d.end_time)}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 时间 -->
|
||||
<script id="payTime" type="text/html">
|
||||
<div class="layui-elip">开始:{{ns.time_to_date(d.pay_start_time)}}</div>
|
||||
<div class="layui-elip">结束:{{ns.time_to_date(d.pay_end_time)}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 推广 -->
|
||||
{include file="app/shop/view/component/promote_show.html"}
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="toolbarAction">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="close">批量关闭</button>
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="operation-wrap" data-presale-id="{{d.presale_id}}">
|
||||
<div class="popup-qrcode-wrap" style="display: none"><img class="popup-qrcode-loadimg" src="__STATIC__/loading/loading.gif"/></div>
|
||||
<div class="table-btn">
|
||||
{{# if(d.status == 1){ }}
|
||||
<a class="layui-btn text-color" lay-event="select">推广</a>
|
||||
{{# } }}
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
{{# if(d.status == 0){ }}
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# }else if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="launch">预售列表</a>
|
||||
<a class="layui-btn" lay-event="close">结束</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn" lay-event="launch">预售列表</a>
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 商品sku -->
|
||||
<script type="text/html" id="skuList">
|
||||
<tr class="js-list-{{d.index}}" id="sku_img_{{d.index}}">
|
||||
<td colspan="8">
|
||||
<ul class="sku-list">
|
||||
{{# for(var i=0; i<d.list.length; i++){ }}
|
||||
<li>
|
||||
<div class="img-wrap">
|
||||
<img layer-src src="{{ns.img(d.list[i].sku_image)}}">
|
||||
</div>
|
||||
<div class="info-wrap">
|
||||
<span class="sku-name" title="{{d.list[i].sku_name}}">{{d.list[i].sku_name}}</span>
|
||||
<span class="price">商品价格:¥{{d.list[i].price}}</span>
|
||||
<span class="price">预售库存:¥{{d.list[i].presale_stock}}</span>
|
||||
<span class="price">定金:¥{{d.list[i].presale_deposit}}</span>
|
||||
<span class="sale_num">定金抵扣金额:{{d.list[i].presale_price}}</span>
|
||||
</div>
|
||||
</li>
|
||||
{{# } }}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var laytpl;
|
||||
$(function () {
|
||||
$("body").off("click", ".contraction").on("click", ".contraction", function () {
|
||||
var presale_id = $(this).attr("data-id");
|
||||
var open = $(this).attr("data-open");
|
||||
var tr = $(this).parent().parent().parent().parent();
|
||||
var index = tr.attr("data-index");
|
||||
if (open == 1) {
|
||||
$(this).children("span").text("+");
|
||||
$(".js-list-" + index).remove();
|
||||
} else {
|
||||
$(this).children("span").text("-");
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/presale/getSkuList"),
|
||||
data: {presale_id: presale_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
|
||||
var sku_list = $("#skuList").html();
|
||||
var data = {
|
||||
list: res.data,
|
||||
index: index
|
||||
};
|
||||
laytpl(sku_list).render(data, function (html) {
|
||||
tr.after(html);
|
||||
});
|
||||
layer.photos({
|
||||
photos: '.img-wrap',
|
||||
anim: 5
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(this).attr("data-open", (open == 0 ? 1 : 0));
|
||||
});
|
||||
|
||||
layui.use(['form', 'element', 'laytpl', 'laydate'], function () {
|
||||
laytpl = layui.laytpl;
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
element.on('tab(presale_tab)', function () {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#presale_list',
|
||||
url: ns.url("presale://shop/presale/lists"),
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox',
|
||||
width: '3%',
|
||||
},{
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: '#goods_info'
|
||||
}, {
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
templet: function (data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'presale_stock',
|
||||
title: '预售总库存',
|
||||
unresize: 'false'
|
||||
}, {
|
||||
field: 'sale_num',
|
||||
title: '销量',
|
||||
unresize: 'false',
|
||||
sort : true
|
||||
}, {
|
||||
title: '定金支付时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
title: '尾款支付时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#payTime'
|
||||
}, {
|
||||
field: 'status_name',
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '8%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
toolbar: '#toolbarAction'
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function (data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
table.on("sort",function (obj) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
order:obj.field,
|
||||
sort:obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function (data) {
|
||||
var status = $(this).attr("data-status");
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 监听工具栏操作
|
||||
table.toolbar(function (obj) {
|
||||
var data = obj.data;
|
||||
if(data.length <= 0) return;
|
||||
var presaleIdAll = [];
|
||||
for (var i in data){
|
||||
presaleIdAll.push(data[i].presale_id);
|
||||
}
|
||||
|
||||
switch (obj.event) {
|
||||
case 'delete':
|
||||
deletePresaleAll(presaleIdAll)
|
||||
break;
|
||||
case 'close':
|
||||
closePresaleAll(presaleIdAll)
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
function deletePresaleAll(data){
|
||||
layer.confirm('确定要删除预售活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/presale/deleteAll"),
|
||||
data: {
|
||||
presale_id: data
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
function closePresaleAll(data){
|
||||
layer.confirm('确定要结束预售活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/presale/finishAll"),
|
||||
data: {
|
||||
presale_id: data
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload();
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function (obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("presale://shop/presale/detail", {"presale_id": data.presale_id});
|
||||
break;
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("presale://shop/presale/edit", {"presale_id": data.presale_id});
|
||||
break;
|
||||
case 'del': //删除
|
||||
deletePresale(data.presale_id);
|
||||
break;
|
||||
case 'close': // 结束
|
||||
closePresale(data.presale_id);
|
||||
break;
|
||||
case 'select': //推广
|
||||
presaleUrl(data);
|
||||
break;
|
||||
case 'launch': //预售订单
|
||||
location.hash = ns.hash("presale://shop/order/lists", {"presale_id": data.presale_id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deletePresale(presale_id) {
|
||||
layer.confirm('确定要删除该预售活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/presale/delete"),
|
||||
data: {
|
||||
presale_id: presale_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 结束
|
||||
function closePresale(presale_id) {
|
||||
|
||||
layer.confirm('确定要结束该预售活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/presale/finish"),
|
||||
data: {
|
||||
presale_id: presale_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
function presaleUrl(data){
|
||||
new PromoteShow({
|
||||
url:ns.url("presale://shop/presale/presaleUrl"),
|
||||
param:{presale_id:data.presale_id},
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("presale://shop/presale/add");
|
||||
}
|
||||
</script>
|
||||
BIN
addon/presale/shop/view/public/img/distribution.png
Executable file
BIN
addon/presale/shop/view/public/img/distribution.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
addon/presale/shop/view/public/img/distribution_new.png
Executable file
BIN
addon/presale/shop/view/public/img/distribution_new.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
addon/presale/shop/view/public/img/distribution_select.png
Executable file
BIN
addon/presale/shop/view/public/img/distribution_select.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
addon/presale/shop/view/public/img/yushou.png
Executable file
BIN
addon/presale/shop/view/public/img/yushou.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
328
addon/presale/shop/view/refund/detail.html
Executable file
328
addon/presale/shop/view/refund/detail.html
Executable file
@@ -0,0 +1,328 @@
|
||||
<link rel="stylesheet" href="SHOP_CSS/order_detail.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="SHOP_CSS/refund_detail.css" />
|
||||
<style>
|
||||
.order-detail-box{display: flex;justify-content: space-around}
|
||||
</style>
|
||||
|
||||
<div class="order-detail">
|
||||
<div class="layui-row layui-col-space1 order-detail-info" >
|
||||
<div class="layui-col-md4 order-detail-left" >
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header nav-title">退款订单信息</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form order-detail-box">
|
||||
<div class="item-box">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单编号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$detail.order_no}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">退款编号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$detail.deposit_refund_no}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">买家:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux"><a target="_blank" href='{:href_url("shop/member/editmember?member_id=".$detail["member_id"])}' style="color: #999">{$detail.name}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">申请人:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$detail.name}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">申请时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{:time_to_date($detail.apply_refund_time)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div class="layui-form-item order-detail-hr">
|
||||
|
||||
</div> -->
|
||||
|
||||
<!-- <div>
|
||||
|
||||
</div> -->
|
||||
{if !empty($detail.final_pay_type_name)}
|
||||
<!-- <div class="layui-form-item order-detail-hr">
|
||||
|
||||
</div> -->
|
||||
<div class="item-box">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">定金:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail.presale_deposit_money}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">定金支付方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail.deposit_pay_type_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">定金退款流水号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail.deposit_refund_no}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">尾款:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail.final_money}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">尾款支付方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail.final_pay_type_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">尾款退款流水号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail.final_refund_no}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<!-- <div class="layui-form-item order-detail-hr">
|
||||
|
||||
</div> -->
|
||||
<div class="item-box1">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">配送方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail['delivery_type_name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系电话:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail['mobile']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item order-detail-hr">
|
||||
</div> -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$detail['order_type_name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md8 order-detail-operation">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">退款状态:{$detail.refund_status_name}</div>
|
||||
<div class="layui-card-body">
|
||||
<p class="order-detail-tips"></p>
|
||||
{if($detail.refund_status == 1)}
|
||||
<a class="layui-btn text-color bg-color-light-9" onclick="agreeRefund({$detail.id})">同意退款</a>
|
||||
<a class="layui-btn text-color bg-color-light-9" onclick="refuseRefund({$detail.id})">拒绝退款</a>
|
||||
{/if}
|
||||
<br>
|
||||
<i class="layui-icon layui-icon-about"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="layui-col-md12">-->
|
||||
<!--<div class="layui-card">-->
|
||||
<!--<div class="layui-card-header">订单商品</div>-->
|
||||
<!--<div class="layui-card-body">-->
|
||||
<!---->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<div class="order-detail-dl">
|
||||
<dl>
|
||||
<dt>温馨提醒</dt>
|
||||
<dd>如果未发货,请点击同意退款给买家。</dd>
|
||||
<dd>如果实际已发货,请主动与买家联系。</dd>
|
||||
<dd>如果订单整体退款后,优惠券和余额会退还给买家。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="layui-row form-wrap">
|
||||
<div class="layui-col-md4">
|
||||
<h4 class="refund-title">售后商品</h4>
|
||||
<ul class="refund-box">
|
||||
<li class="refund-item">
|
||||
<div class="goods-item">
|
||||
<div class="image-wrap">
|
||||
{if condition="$detail.sku_image"}
|
||||
<img alt="商品图片" layer-src src="{:img($detail.sku_image,'small')}">
|
||||
{/if}
|
||||
</div>
|
||||
<div class="detail-wrap">
|
||||
<h4 class="title"><span style="color: #999;font-weight: 500">{$detail.sku_name}</span></h4>
|
||||
<p class="gray"></p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<h4 class="refund-title">售后信息</h4>
|
||||
<ul class="refund-box">
|
||||
|
||||
<li class="refund-item">
|
||||
<label class="refund-label">退款金额:</label>
|
||||
<div class="refund-content"><span class="refund-money">¥{$detail.refund_money}</span> </div>
|
||||
</li>
|
||||
<li class="refund-item">
|
||||
<label class="refund-label">联系方式:</label>
|
||||
<div class="refund-content">{$detail.mobile}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="layui-col-md4">
|
||||
<h4 class="refund-title">购买信息</h4>
|
||||
<ul class="refund-box">
|
||||
<li class="refund-item">
|
||||
<label class="refund-label">商品单价:</label>
|
||||
<div class="refund-content"><span class="refund-money">¥{$detail.price}</span> x{$detail.num}件</div>
|
||||
</li>
|
||||
<li class="refund-item">
|
||||
<label class="refund-label">实付金额:</label>
|
||||
<div class="refund-content"><span class="refund-money">¥{$detail['goods_money'] - ($detail['presale_money'] - $detail['presale_deposit_money'])}</span></div>
|
||||
</li>
|
||||
<li class="refund-item">
|
||||
<label class="refund-label">订单编号:</label>
|
||||
<div class="refund-content"> <a target="_blank" class="text-color" href="{:href_url('shop/order/detail',['order_id'=>$detail['id']])}">{$detail.order_no}</a></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 维权操作 -->
|
||||
<script>
|
||||
var repeat_flag = false;//防重复标识
|
||||
//同意退款
|
||||
function agreeRefund(id){
|
||||
layer.confirm('确定同意该退款申请吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/refund/agree"),
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
//拒绝退款
|
||||
var refuse_repeat_flag = false;
|
||||
function refuseRefund(id) {
|
||||
layer.prompt({
|
||||
title: '拒绝理由',
|
||||
formType: 2,
|
||||
yes: function(index, layero) {
|
||||
var value = layero.find(".layui-layer-input").val();
|
||||
|
||||
if (value) {
|
||||
if(refuse_repeat_flag) return false;
|
||||
refuse_repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/refund/refuse"),
|
||||
data: {id:id,refuse_reason:value},
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //HTTP请求类型
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
refuse_repeat_flag = false;
|
||||
|
||||
if (res.code >= 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
} else {
|
||||
layer.msg('请输入拒绝理由!', {icon: 5, anim: 6});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
383
addon/presale/shop/view/refund/lists.html
Executable file
383
addon/presale/shop/view/refund/lists.html
Executable file
@@ -0,0 +1,383 @@
|
||||
<style>
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
.layui-layout-admin .screen{margin-top: 15px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-collapse tips-wrap">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">操作提示</h2>
|
||||
<ul class="layui-colla-content layui-show">
|
||||
<li>商品预售展示商品预售相关信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">搜索方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="order_label" >
|
||||
{foreach $order_label_list as $k => $label_val}
|
||||
<option value="{$k}">{$label_val}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="search" autocomplete="off" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">下单时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(7, this);return false;">近7天</button>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(30, this);return false;">近30天</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">订单类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="order_type" lay-filter="order_type">
|
||||
{foreach $order_type_list as $order_type_k => $order_type_val}
|
||||
<option value="{$order_type_val.type}">{$order_type_val.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">订单来源:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="order_from">
|
||||
<option value="">全部</option>
|
||||
{foreach $order_from_list as $order_from_k => $order_from_v}
|
||||
<option value="{$order_from_k}">{$order_from_v['name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">定金付款方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="deposit_pay_type" >
|
||||
<option value="">全部</option>
|
||||
{foreach pay_type_list as $pay_type_k => $pay_type_v}
|
||||
<option value="{$pay_type_k}">{$pay_type_v}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">尾款付款方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="final_pay_type" >
|
||||
<option value="">全部</option>
|
||||
{foreach pay_type_list as $pay_type_k => $pay_type_v}
|
||||
<option value="{$pay_type_k}">{$pay_type_v}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<!-- <div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加商品预售</button>
|
||||
</div> -->
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="presale_tab">
|
||||
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="">全部</li>
|
||||
{foreach $order_status_list as $status_val}
|
||||
<li data-status="{$status_val.status}">{$status_val.name}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<table id="presale_list" lay-filter="presale_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.sku_image){ }}
|
||||
<img layer-src src="{{ns.img(d.sku_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{{d.sku_name}}">{{d.sku_name}}</a>
|
||||
<a href="javascript:;" class="multi-line-hiding" title="">¥ {{ d.price }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 金额 -->
|
||||
<script id="price" type="text/html">
|
||||
<div class="layui-elip">定金:¥{{ d.presale_deposit_money }}</div>
|
||||
<div class="layui-elip">尾款:¥{{ d.final_money }}</div>
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="edit">详情</a>
|
||||
{{# if(d.refund_status == 1){ }}
|
||||
<a class="layui-btn" lay-event="agree">同意退款</a>
|
||||
<a class="layui-btn" lay-event="refuse">拒绝退款</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var laytpl,table,form,laydate,element,repeat_flag;
|
||||
layui.use(['form', 'element','laydate','laytpl'], function() {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
laydate = layui.laydate;
|
||||
element = layui.element;
|
||||
repeat_flag = false; //防重复标识
|
||||
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
element.on('tab(presale_tab)', function() {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'refund_status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#presale_list',
|
||||
url: ns.url("presale://shop/refund/lists"),
|
||||
cols: [
|
||||
[{
|
||||
field: 'deposit_refund_no',
|
||||
title: '退款编号',
|
||||
unresize: 'false',
|
||||
width:'10%'
|
||||
},{
|
||||
field: 'order_no',
|
||||
title: '订单编号',
|
||||
unresize: 'false',
|
||||
width:'10%'
|
||||
},{
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
templet:'#goods',
|
||||
width:'25%'
|
||||
}, {
|
||||
field:'num',
|
||||
title: '购买数量',
|
||||
unresize: 'false',
|
||||
templet:function(data){
|
||||
return data.num + '件';
|
||||
},
|
||||
width:'6%'
|
||||
}, {
|
||||
title: '金额',
|
||||
unresize: 'false',
|
||||
templet:'#price',
|
||||
width:'10%'
|
||||
}, {
|
||||
title: '退款金额',
|
||||
templet:function(data){
|
||||
return '¥' + data.refund_money;
|
||||
}
|
||||
}, {
|
||||
field:'refund_status_name',
|
||||
title: '退款状态',
|
||||
unresize: 'false'
|
||||
}, {
|
||||
title: '申请时间',
|
||||
unresize: 'false',
|
||||
templet:function(data){
|
||||
return ns.time_to_date(data.apply_refund_time);
|
||||
},
|
||||
width:"10%"
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'edit': //查看
|
||||
window.open(ns.href("presale://shop/refund/detail", {"id": data.id}));
|
||||
break;
|
||||
case 'agree': //同意
|
||||
agreeRefund(data.id);
|
||||
break;
|
||||
case 'refuse'://拒绝
|
||||
refuseRefund(data.id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//同意退款
|
||||
function agreeRefund(id){
|
||||
layer.confirm('确定同意该退款申请吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/refund/agree"),
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
//拒绝退款
|
||||
var refuse_repeat_flag = false;
|
||||
function refuseRefund(id) {
|
||||
|
||||
layer.prompt({
|
||||
title: '拒绝理由',
|
||||
formType: 2,
|
||||
yes: function(index, layero) {
|
||||
var value = layero.find(".layui-layer-input").val();
|
||||
|
||||
if (value) {
|
||||
if(refuse_repeat_flag) return false;
|
||||
refuse_repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("presale://shop/refund/refuse"),
|
||||
data: {id:id,refuse_reason:value},
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //HTTP请求类型
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
refuse_repeat_flag = false;
|
||||
|
||||
if (res.code >= 0) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
} else {
|
||||
layer.msg('请输入拒绝理由!', {icon: 5, anim: 6});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 七天时间
|
||||
*/
|
||||
function datePick(date_num,event_obj){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
$(event_obj).addClass('selected');
|
||||
// alert(new Date().format("yyyy-MM-dd hh:mm"));
|
||||
Date.prototype.Format = function (fmt,date_num) { //author: meizz
|
||||
this.setDate(this.getDate()-date_num);
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"H+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
||||
// var now_time = new Date().Format("yyyy-MM-dd HH:mm:ss",0);//当前日期
|
||||
var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
|
||||
var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
|
||||
$("input[name=start_time]").val(before_time,0);
|
||||
$("input[name=end_time]").val(now_time,date_num-1);
|
||||
}
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("presale://shop/presale/add");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user