Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
This commit is contained in:
commit
e7fef4b83d
@ -31,8 +31,8 @@ class PayController extends BaseApiController
|
|||||||
$extra['transaction_id'] = $ciphertext['transaction_id'];
|
$extra['transaction_id'] = $ciphertext['transaction_id'];
|
||||||
$attach = $ciphertext['attach'];
|
$attach = $ciphertext['attach'];
|
||||||
switch ($attach) {
|
switch ($attach) {
|
||||||
case 'cashierclass':
|
case 'wechat_common':
|
||||||
PayNotifyLogic::handle('cashierclass', $ciphertext['out_trade_no'], $ciphertext);
|
PayNotifyLogic::handle('wechat_common', $ciphertext['out_trade_no'], $ciphertext);
|
||||||
$app->wechat->success();
|
$app->wechat->success();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ class PayController extends BaseApiController
|
|||||||
|
|
||||||
$res = $app->wechat->query($order);
|
$res = $app->wechat->query($order);
|
||||||
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
||||||
PayNotifyLogic::handle('cashierclass', $res['out_trade_no'], $res);
|
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||||
return $this->success('支付成功');
|
return $this->success('支付成功');
|
||||||
} else {
|
} else {
|
||||||
return $this->fail('订单支付中');
|
return $this->fail('订单支付中');
|
||||||
|
25
app/api/controller/product/ProductController.php
Normal file
25
app/api/controller/product/ProductController.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\product;
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\product\ProductLists;
|
||||||
|
|
||||||
|
class ProductController extends BaseApiController{
|
||||||
|
public $notNeedLogin = ['lists'];
|
||||||
|
/**
|
||||||
|
* 商品列表
|
||||||
|
*/
|
||||||
|
public function lists(){
|
||||||
|
|
||||||
|
return $this->dataLists(new ProductLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品列表
|
||||||
|
*/
|
||||||
|
public function mer_list(){
|
||||||
|
$this->request->__set('mer_id',$this->request->userInfo['merchant']['mer_id']??0);
|
||||||
|
return $this->dataLists(new ProductLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
215
app/api/lists/product/ProductLists.php
Normal file
215
app/api/lists/product/ProductLists.php
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\cate\Cate;
|
||||||
|
//use app\common\model\goods\GoodsLabel;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品列表列表
|
||||||
|
* Class goods
|
||||||
|
* @package app\api\goods
|
||||||
|
*/
|
||||||
|
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
$name=$this->request->get('name');
|
||||||
|
// $where= [
|
||||||
|
// '=' => ['class']
|
||||||
|
// ];
|
||||||
|
// if($name && preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){
|
||||||
|
// $where['%like%']=['store_name'];
|
||||||
|
$where[] = ['store_name','like','%'.$name.'%'];
|
||||||
|
// }else{
|
||||||
|
// $where['=']=['bar_code','cate_id'];
|
||||||
|
// }
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置支持排序字段
|
||||||
|
* @return string[]
|
||||||
|
* @date 2021/12/29 10:07
|
||||||
|
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||||
|
*/
|
||||||
|
public function setSortFields(): array
|
||||||
|
{
|
||||||
|
// return ['sell' => 'sell', 'sales' => 'sales',];
|
||||||
|
return ['sell' => 'ot_price', 'sales' => 'sales',];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置默认排序
|
||||||
|
* @return string[]
|
||||||
|
* @date 2021/12/29 10:06
|
||||||
|
*/
|
||||||
|
public function setDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return ['sales' => 'desc','ot_price' => 'asc'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品列表列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
$class_all=$this->request->get('class_all');
|
||||||
|
$name = $this->request->get('name','');
|
||||||
|
$order_param = $this->request->get('order');
|
||||||
|
$store_id = $this->request->get('store_id',2);
|
||||||
|
$where=[];
|
||||||
|
$order = [];
|
||||||
|
if($class_all){
|
||||||
|
$arr=[];
|
||||||
|
$arr2=[];
|
||||||
|
$arr=Cate::where('pid',$class_all)->column('id');
|
||||||
|
if($arr){
|
||||||
|
$arr2=Cate::where('pid','in',$arr)->column('id');
|
||||||
|
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
||||||
|
}else{
|
||||||
|
$where[]=['cate_id','=',$class_all];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!empty($order_param)){
|
||||||
|
if($order_param == 'asc'){
|
||||||
|
$order['price'] = 'asc';
|
||||||
|
}elseif ($order_param == 'desc') {
|
||||||
|
$order['price'] = 'desc';
|
||||||
|
}elseif ($order_param=='sales') {
|
||||||
|
$order['sales'] = 'desc';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$order['id'] = 'desc';
|
||||||
|
}
|
||||||
|
if($name){
|
||||||
|
if(preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){
|
||||||
|
$where[] = ['store_name','like','%'.$name.'%'];
|
||||||
|
}else{
|
||||||
|
$where[] = ['bar_code','=',$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$where[]=['store_id','=',$store_id];
|
||||||
|
$data =StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||||
|
->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->with(['className'])
|
||||||
|
->order($order)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
foreach ($data as $k=> &$v){
|
||||||
|
$info= StoreProduct::alias('p')
|
||||||
|
->leftJoin('store_product_unit t','t.id = p.unit')
|
||||||
|
->where('p.id',$v['product_id'])
|
||||||
|
->field('p.unit,t.name,t.is_bulk')->find()??[];
|
||||||
|
if($info){
|
||||||
|
$v['unit_name'] = $info['name']??'';
|
||||||
|
$v['is_bulk'] = $info['is_bulk']??'';
|
||||||
|
}else{
|
||||||
|
unset($data[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array_values($data);
|
||||||
|
// return StoreProduct::where($this->searchWhere)->where($where)
|
||||||
|
// ->field(['id', 'cate_id','store_name','unit', 'ot_price', 'bar_code','image','sales','store_info'])
|
||||||
|
// ->limit($this->limitOffset, $this->limitLength)
|
||||||
|
// ->with(['className','unitName'])
|
||||||
|
// ->order($order)
|
||||||
|
// ->select()
|
||||||
|
// ->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品列表数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
$class_all=$this->request->get('class_all');
|
||||||
|
$order_param = $this->request->get('order');
|
||||||
|
$store_id = $this->request->get('store_id',2);
|
||||||
|
$name = $this->request->get('name','');
|
||||||
|
$where=[];
|
||||||
|
$order = [];
|
||||||
|
if($class_all){
|
||||||
|
$arr=[];
|
||||||
|
$arr2=[];
|
||||||
|
$arr=Cate::where('pid',$class_all)->column('id');
|
||||||
|
if($arr){
|
||||||
|
$arr2=Cate::where('pid','in',$arr)->column('id');
|
||||||
|
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
||||||
|
}else{
|
||||||
|
$where[]=['cate_id','=',$class_all];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!empty($order_param)){
|
||||||
|
if($order_param == 'asc'){
|
||||||
|
$order['price'] = 'asc';
|
||||||
|
}elseif ($order_param == 'desc') {
|
||||||
|
$order['price'] = 'desc';
|
||||||
|
}elseif ($order_param=='sales') {
|
||||||
|
$order['sales'] = 'desc';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$order['id'] = 'desc';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($name){
|
||||||
|
if(preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){
|
||||||
|
$where[] = ['store_name','like','%'.$name.'%'];
|
||||||
|
}else{
|
||||||
|
$where[] = ['bar_code','=',$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$where[]=['store_id','=',$store_id];
|
||||||
|
|
||||||
|
$data =StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||||
|
->field(['id', 'product_id'])
|
||||||
|
->order($order)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
foreach ($data as $k=> &$v){
|
||||||
|
$info= StoreProduct::alias('p')
|
||||||
|
->leftJoin('store_product_unit t','t.id = p.unit')
|
||||||
|
->where('p.id',$v['product_id'])
|
||||||
|
->field('p.unit,t.name,t.is_bulk')->find()??[];
|
||||||
|
if($info){
|
||||||
|
$v['unit_name'] = $info['name']??'';
|
||||||
|
$v['is_bulk'] = $info['is_bulk']??'';
|
||||||
|
}else{
|
||||||
|
unset($data[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return count($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -41,8 +41,8 @@ class OrderLogic extends BaseLogic
|
|||||||
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [])
|
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [])
|
||||||
{
|
{
|
||||||
|
|
||||||
$where = ['is_pay' => 0, 'is_fail' => 0];
|
$where = ['is_pay' => 0, 'is_del' => 0];
|
||||||
$cart_select = Cart::whereIn('cart_id', $cartId)->where($where)->field('goods_id as goods,cart_num')->select()->toArray();
|
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('product_id as goods,cart_num')->select()->toArray();
|
||||||
if (empty($cart_select)) {
|
if (empty($cart_select)) {
|
||||||
self::setError('购物车为空');
|
self::setError('购物车为空');
|
||||||
return false;
|
return false;
|
||||||
@ -51,24 +51,26 @@ class OrderLogic extends BaseLogic
|
|||||||
self::$total = 0;
|
self::$total = 0;
|
||||||
/** 计算价格 */
|
/** 计算价格 */
|
||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
$find = Goods::where(['id' => $v['goods']])->field('name,imgs,unit,sell')->find();
|
$find = StoreProduct::where(['id' => $v['goods']])->field('store_name,image,unit,price')->find();
|
||||||
if(!$find){
|
if(!$find){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$cart_select[$k]['total'] = bcmul($v['cart_num'], $find['sell'], 2);
|
$cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2);//钱
|
||||||
$cart_select[$k]['price'] = $find['sell'];
|
$cart_select[$k]['price'] = $find['price'];
|
||||||
$cart_select[$k]['name'] = $find['name'];
|
$cart_select[$k]['name'] = $find['store_name'];
|
||||||
$cart_select[$k]['imgs'] = $find['imgs'];
|
$cart_select[$k]['imgs'] = $find['image'];
|
||||||
$cart_select[$k]['unit_name'] = Unit::where(['id' => $find['unit']])->value('name');
|
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||||
self::$total=bcadd(self::$total, $cart_select[$k]['total'], 2);
|
self::$total=bcadd(self::$total, $cart_select[$k]['total'], 2);
|
||||||
}
|
}
|
||||||
$order = [
|
$order = [
|
||||||
'time' => time(),
|
'add_time' => time(),
|
||||||
'number' => getNewOrderId('PF'),
|
'create_time' => time(),
|
||||||
'total' => self::$total,
|
'order_id' => getNewOrderId('PF'),
|
||||||
|
'total_price' => self::$total,//总价
|
||||||
|
'total_num' => count($cart_select),//总数
|
||||||
'pay_type' => $params['pay_type'] ?? 0,
|
'pay_type' => $params['pay_type'] ?? 0,
|
||||||
'cart_id' => implode(',', $cartId),
|
'cart_id' => implode(',', $cartId),
|
||||||
'delivery_msg'=>' 预计48小时发货 '
|
// 'delivery_msg'=>' 预计48小时发货 '
|
||||||
];
|
];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
@ -115,7 +117,7 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$order = Cashierclass::create($_order);
|
$order = StoreOrder::create($_order);
|
||||||
$goods_list = $orderInfo['cart_list'];
|
$goods_list = $orderInfo['cart_list'];
|
||||||
foreach ($goods_list as $k => $v) {
|
foreach ($goods_list as $k => $v) {
|
||||||
$goods_list[$k]['pid'] = $order->id;
|
$goods_list[$k]['pid'] = $order->id;
|
||||||
@ -126,8 +128,8 @@ class OrderLogic extends BaseLogic
|
|||||||
$goods_list[$k]['warehouse'] = 0;
|
$goods_list[$k]['warehouse'] = 0;
|
||||||
$goods_list[$k]['nums'] = $v['cart_num'];
|
$goods_list[$k]['nums'] = $v['cart_num'];
|
||||||
}
|
}
|
||||||
(new Cashierinfo())->saveAll($goods_list);
|
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||||
$where = ['is_pay' => 0, 'is_fail' => 0];
|
$where = ['is_pay' => 0, 'is_del' => 0];
|
||||||
Cart::whereIn('cart_id', $cartId)->where($where)->update(['is_pay'=>1]);
|
Cart::whereIn('cart_id', $cartId)->where($where)->update(['is_pay'=>1]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $order;
|
return $order;
|
||||||
|
84
app/common/enum/OrderEnum.php
Normal file
84
app/common/enum/OrderEnum.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\enum;
|
||||||
|
|
||||||
|
|
||||||
|
class OrderEnum
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 流水类型
|
||||||
|
* @USER_ORDER_PAY 用户订单支付
|
||||||
|
* @CASHIER_ORDER_PAY 收银台支付
|
||||||
|
* @CASHIER_CASH_ORDER_PAY 收银台现金支付
|
||||||
|
* @MERCHANT_ORDER_OBTAINS 商户订单获得
|
||||||
|
* @ORDER_HANDLING_FEES 订单手续费
|
||||||
|
* @MERCHANT_ORDER_PAY 商户订单支付
|
||||||
|
* @PLATFORM_ORDER_OBTAINS 平台订单获得
|
||||||
|
* @SUPPLIER_ORDER_OBTAINS 供应链订单获得
|
||||||
|
* @PLATFORM_ORDER_PAY 平台订单支付
|
||||||
|
* @SYSTEM_SET 系统设置
|
||||||
|
*/
|
||||||
|
const USER_ORDER_PAY = 1;
|
||||||
|
const MERCHANT_ORDER_OBTAINS = 2;
|
||||||
|
const ORDER_HANDLING_FEES = 3;
|
||||||
|
const MERCHANT_ORDER_PAY = 4;
|
||||||
|
const PLATFORM_ORDER_OBTAINS = 5;
|
||||||
|
const SUPPLIER_ORDER_OBTAINS = 6;
|
||||||
|
const PLATFORM_ORDER_PAY = 7;
|
||||||
|
const SYSTEM_SET = 8;
|
||||||
|
const CASHIER_ORDER_PAY = 9;
|
||||||
|
const CASHIER_CASH_ORDER_PAY = 10;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收入支出类型
|
||||||
|
* @EXPENDITURE 支出
|
||||||
|
* @INCOME 收入
|
||||||
|
*/
|
||||||
|
const EXPENDITURE =0;
|
||||||
|
const INCOME =1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账户类型
|
||||||
|
* @USER 用户
|
||||||
|
* @MERCHANT 商户
|
||||||
|
* @PLATFORM 平台
|
||||||
|
* @SUPPLIER 供应链
|
||||||
|
* @SYSTEM 系统
|
||||||
|
*/
|
||||||
|
const USER =0;
|
||||||
|
const MERCHANT =1;
|
||||||
|
const PLATFORM =2;
|
||||||
|
const SUPPLIER =3;
|
||||||
|
const SYSTEM=4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取支付类型
|
||||||
|
* @param bool $value
|
||||||
|
* @return string|string[]
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2023/2/23 15:36
|
||||||
|
*/
|
||||||
|
public static function getFinancialType($value = true)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
self::USER_ORDER_PAY=>'用户订单支付',
|
||||||
|
self::MERCHANT_ORDER_PAY=>'商户订单支付',
|
||||||
|
self::PLATFORM_ORDER_PAY=>'平台订单支付',
|
||||||
|
self::MERCHANT_ORDER_OBTAINS=>'商户订单获得',
|
||||||
|
self::ORDER_HANDLING_FEES=>'订单手续费',
|
||||||
|
self::PLATFORM_ORDER_OBTAINS=>'平台订单获得',
|
||||||
|
self::SUPPLIER_ORDER_OBTAINS=>'供应商订单获得',
|
||||||
|
self::SYSTEM_SET=>'平台设置',
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
if ($value === true) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
return $data[$value] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -7,9 +7,11 @@ use app\common\enum\PayEnum;
|
|||||||
use app\common\enum\user\AccountLogEnum;
|
use app\common\enum\user\AccountLogEnum;
|
||||||
use app\common\model\operation\Opurchaseclass;
|
use app\common\model\operation\Opurchaseclass;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
use app\common\model\order\FinancialRecord;
|
use app\common\model\financial_record\FinancialRecord;
|
||||||
use app\common\model\recharge\RechargeOrder;
|
use app\common\model\recharge\RechargeOrder;
|
||||||
use app\common\model\retail\Cashierclass;
|
use app\common\model\retail\Cashierclass;
|
||||||
|
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||||
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\service\PushService;
|
use app\common\service\PushService;
|
||||||
use app\common\service\wechat\WeChatMnpService;
|
use app\common\service\wechat\WeChatMnpService;
|
||||||
@ -48,15 +50,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 零售回调
|
* @notes 微信通用回调
|
||||||
* @param $orderSn
|
* @param $orderSn
|
||||||
* @param array $extra
|
* @param array $extra
|
||||||
* @author 段誉
|
|
||||||
* @date 2023/2/27 15:28
|
* @date 2023/2/27 15:28
|
||||||
*/
|
*/
|
||||||
public static function cashierclass($orderSn, $extra = [])
|
public static function wechat_common($orderSn, $extra = [])
|
||||||
{
|
{
|
||||||
$order = Cashierclass::where('number', $orderSn)->findOrEmpty();
|
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
|
||||||
|
|
||||||
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
||||||
return true;
|
return true;
|
||||||
@ -64,7 +65,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$financial_type = OrderEnum::USER_ORDER_PAY;
|
$financial_type = OrderEnum::USER_ORDER_PAY;
|
||||||
$financial_type2 = OrderEnum::MERCHANT_ORDER_OBTAINS;
|
$financial_type2 = OrderEnum::MERCHANT_ORDER_OBTAINS;
|
||||||
if ($order->pay_type != 10) {
|
if ($order->pay_type != 10) {
|
||||||
$order->money = bcdiv($extra['amount']['payer_total'], 100, 2);
|
$order->pay_price = bcdiv($extra['amount']['payer_total'], 100, 2);
|
||||||
$order->paid = 1;
|
$order->paid = 1;
|
||||||
$order->status = 1;
|
$order->status = 1;
|
||||||
$order->save();
|
$order->save();
|
||||||
@ -81,128 +82,54 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$record[] = [
|
$record[] = [
|
||||||
'financial_record_sn' => $extra['transaction_id'],
|
'financial_record_sn' => $extra['transaction_id'],
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'order_sn' => $order['order_id'],
|
||||||
'user_id' => $order['uid'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => $financial_type,
|
'financial_type' => $financial_type,
|
||||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
'financial_pm' => OrderEnum::EXPENDITURE,
|
||||||
'number' => $order['actual'],
|
'number' => $order['pay_price'],
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'type' => OrderEnum::USER,
|
'type' => OrderEnum::USER,
|
||||||
'mer_id' => $order['merchant'],
|
'store_id' => $order['store_id'],
|
||||||
|
'staff_id' => $order['staff_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
//商户获得流水
|
//商户获得流水
|
||||||
$record[] = [
|
$record[] = [
|
||||||
'financial_record_sn' => $extra['transaction_id'],
|
'financial_record_sn' => $extra['transaction_id'],
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'order_sn' => $order['order_id'],
|
||||||
'user_id' => $order['uid'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => $financial_type2,
|
'financial_type' => $financial_type2,
|
||||||
'financial_pm' => OrderEnum::INCOME,
|
'financial_pm' => OrderEnum::INCOME,
|
||||||
'number' => $order['actual'],
|
'number' => $order['pay_price'],
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'type' => OrderEnum::MERCHANT,
|
'type' => OrderEnum::MERCHANT,
|
||||||
'mer_id' => $order['merchant'],
|
'store_id' => $order['store_id'],
|
||||||
|
'staff_id' => $order['staff_id'],
|
||||||
];
|
];
|
||||||
(new FinancialRecord())->saveAll($record);
|
(new FinancialRecord())->saveAll($record);
|
||||||
|
|
||||||
|
|
||||||
if ($order->pay_type == 9) {
|
if ($order->pay_type == 9) {
|
||||||
$extra['create_time'] = $order['create_time'];
|
$extra['create_time'] = $order['create_time'];
|
||||||
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
PushService::push('store_merchant_' . $order['id'], $order['id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
||||||
} else {
|
} else {
|
||||||
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
PushService::push('store_merchant_' . $order['id'], $order['id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||||
Redis::send('push-platform-print', ['order_id' => $order['id']], 60);
|
Redis::send('push-platform-print', ['order_id' => $order['id']], 60);
|
||||||
Db::name('order_middle')->insert(['c_order_id' =>$order['id']]);
|
Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
|
||||||
}
|
}
|
||||||
if (!empty($extra['payer']['openid']) && $order->pay_type != 9) {
|
if (!empty($extra['payer']['openid']) && $order->pay_type != 9) {
|
||||||
Redis::send('push-delivery', ['order_id' => $orderSn, 'openid' => $extra['payer']['openid']], 5);
|
Redis::send('push-delivery', ['order_sn' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 采购订单支付成功
|
|
||||||
*/
|
|
||||||
public static function opurchaseclass($orderSn, $extra = [])
|
|
||||||
{
|
|
||||||
$order = Opurchaseclass::where('number', $orderSn)->findOrEmpty();
|
|
||||||
$order_arr = explode(',', $order['order_arr']);
|
|
||||||
(new FinancialRecord())->where('order_id', 'in', $order_arr)->update(['status' => 1]);
|
|
||||||
Db::name('order_middle')->where('c_order_id', 'in', $order_arr)->update(['b_order_id' => $order['id']]);
|
|
||||||
$time = time();
|
|
||||||
//商户支出流水
|
|
||||||
$record[] = [
|
|
||||||
'financial_record_sn' => $time,
|
|
||||||
'order_id' => $order['id'],
|
|
||||||
'number_sn' => $order['number'],
|
|
||||||
'user_id' => $order['uid'],
|
|
||||||
'financial_type' => OrderEnum::MERCHANT_ORDER_PAY,
|
|
||||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
|
||||||
'number' => $order['actual'],
|
|
||||||
'status' => 1,
|
|
||||||
'type' => OrderEnum::MERCHANT,
|
|
||||||
'mer_id' => $order['merchant'],
|
|
||||||
];
|
|
||||||
//平台获得流水
|
|
||||||
$record[] = [
|
|
||||||
'financial_record_sn' => $time,
|
|
||||||
'order_id' => $order['id'],
|
|
||||||
'number_sn' => $order['number'],
|
|
||||||
'user_id' => $order['uid'],
|
|
||||||
'financial_type' => OrderEnum::PLATFORM_ORDER_OBTAINS,
|
|
||||||
'financial_pm' => OrderEnum::INCOME,
|
|
||||||
'number' => $order['actual'],
|
|
||||||
'status' => 1,
|
|
||||||
'type' => OrderEnum::PLATFORM,
|
|
||||||
'mer_id' => $order['merchant'],
|
|
||||||
];
|
|
||||||
(new FinancialRecord())->saveAll($record);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 平台采购订单支付成功
|
|
||||||
*/
|
|
||||||
public static function operated($orderSn, $extra = [])
|
|
||||||
{
|
|
||||||
$order = Opurchaseclass::where('number', $orderSn)->findOrEmpty();
|
|
||||||
$order_arr = explode(',', $order['order_arr']);
|
|
||||||
(new FinancialRecord())->where('order_id', 'in', $order_arr)->update(['status' => 1]);
|
|
||||||
Db::name('order_middle')->where('b_order_id', 'in', $order_arr)->update(['p_order_id' => $order['id']]);
|
|
||||||
$time = time();
|
|
||||||
//平台支出流水
|
|
||||||
$record[] = [
|
|
||||||
'financial_record_sn' => $time,
|
|
||||||
'order_id' => $order['id'],
|
|
||||||
'number_sn' => $order['number'],
|
|
||||||
'user_id' => $order['uid'],
|
|
||||||
'financial_type' => OrderEnum::PLATFORM_ORDER_PAY,
|
|
||||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
|
||||||
'number' => $order['actual'],
|
|
||||||
'status' => 1,
|
|
||||||
'type' => OrderEnum::PLATFORM,
|
|
||||||
'mer_id' => getenv('OPERATED'),
|
|
||||||
];
|
|
||||||
// //平台获得流水
|
|
||||||
// $record[] = [
|
|
||||||
// 'financial_record_sn' => $time,
|
|
||||||
// 'order_id' => $order['id'],
|
|
||||||
// 'number_sn' => $order['number'],
|
|
||||||
// 'user_id' => $order['uid'],
|
|
||||||
// 'financial_type' => OrderEnum::PLATFORM_ORDER_OBTAINS,
|
|
||||||
// 'financial_pm' => OrderEnum::INCOME,
|
|
||||||
// 'number' => $order['actual'],
|
|
||||||
// 'status' => 1,
|
|
||||||
// 'type' => OrderEnum::PLATFORM,
|
|
||||||
// 'mer_id' => $order['merchant'],
|
|
||||||
// ];
|
|
||||||
(new FinancialRecord())->saveAll($record);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 现金支付
|
* 现金支付
|
||||||
*/
|
*/
|
||||||
public static function cash_pay($orderSn)
|
public static function cash_pay($orderSn)
|
||||||
{
|
{
|
||||||
$order = Cashierclass::where('number', $orderSn)->findOrEmpty();
|
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
|
||||||
|
|
||||||
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
||||||
return true;
|
return true;
|
||||||
@ -214,14 +141,15 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$record[] = [
|
$record[] = [
|
||||||
'financial_record_sn' => time(),
|
'financial_record_sn' => time(),
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'order_sn' => $order['order_id'],
|
||||||
'user_id' => $order['uid'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => OrderEnum::CASHIER_CASH_ORDER_PAY,
|
'financial_type' => OrderEnum::CASHIER_CASH_ORDER_PAY,
|
||||||
'financial_pm' => OrderEnum::INCOME,
|
'financial_pm' => OrderEnum::INCOME,
|
||||||
'number' => $order['actual'],
|
'number' => $order['pay_price'],
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'type' => OrderEnum::MERCHANT,
|
'type' => OrderEnum::MERCHANT,
|
||||||
'mer_id' => $order['merchant'],
|
'store_id' => $order['store_id'],
|
||||||
|
'staff_id' => $order['staff_id'],
|
||||||
];
|
];
|
||||||
(new FinancialRecord())->saveAll($record);
|
(new FinancialRecord())->saveAll($record);
|
||||||
}
|
}
|
||||||
@ -235,7 +163,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function alipay_cashier($orderSn, $extra = [])
|
public static function alipay_cashier($orderSn, $extra = [])
|
||||||
{
|
{
|
||||||
$order = Cashierclass::where('number', $orderSn)->findOrEmpty();
|
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
|
||||||
|
|
||||||
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
||||||
return true;
|
return true;
|
||||||
@ -260,7 +188,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$record[] = [
|
$record[] = [
|
||||||
'financial_record_sn' => $extra['trade_no'],
|
'financial_record_sn' => $extra['trade_no'],
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'order_sn' => $order['order_id'],
|
||||||
'user_id' => $order['uid'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => $financial_type,
|
'financial_type' => $financial_type,
|
||||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
'financial_pm' => OrderEnum::EXPENDITURE,
|
||||||
@ -274,7 +202,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$record[] = [
|
$record[] = [
|
||||||
'financial_record_sn' => $extra['trade_no'],
|
'financial_record_sn' => $extra['trade_no'],
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'order_sn' => $order['order_id'],
|
||||||
'user_id' => $order['uid'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => $financial_type2,
|
'financial_type' => $financial_type2,
|
||||||
'financial_pm' => OrderEnum::INCOME,
|
'financial_pm' => OrderEnum::INCOME,
|
||||||
@ -288,10 +216,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
|
|
||||||
if ($order->pay_type == 9) {
|
if ($order->pay_type == 9) {
|
||||||
$extra['create_time'] = $order['create_time'];
|
$extra['create_time'] = $order['create_time'];
|
||||||
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
PushService::push('store_merchant_' . $order['id'], $order['id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
||||||
} else {
|
} else {
|
||||||
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
PushService::push('store_merchant_' . $order['id'], $order['id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||||
Redis::send('push-platform-print', ['order_id' => $order['id']], 60);
|
Redis::send('push-platform-print', ['order_sn' => $order['order_id']], 60);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
22
app/common/model/financial_record/FinancialRecord.php
Normal file
22
app/common/model/financial_record/FinancialRecord.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\financial_record;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 财务流水模型
|
||||||
|
* Class FinancialRecord
|
||||||
|
* @package app\common\model\financial_record
|
||||||
|
*/
|
||||||
|
class FinancialRecord extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'financial_record';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,9 @@ namespace app\common\model\store_branch_product;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -19,4 +22,19 @@ class StoreBranchProduct extends BaseModel
|
|||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function className()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreCategory::class,'id','cate_id')->bind(['class_name'=>'name']);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreProduct::class,'id','product_id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ namespace app\common\model\store_product;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
@ -26,4 +27,12 @@ class StoreProduct extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function className()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreCategory::class,'id','cate_id')->bind(['class_name'=>'name']);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user