调整订单核销
This commit is contained in:
parent
34cad62c8e
commit
0298e42057
app
admin/lists/store_branch_product
api
common
store/controller/store_product
@ -47,7 +47,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
{
|
{
|
||||||
$status = $this->params['status'] ?? '';
|
$status = $this->params['status'] ?? '';
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
return StoreBranchProduct::where($this->searchWhere)
|
||||||
->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost'])
|
->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status'])
|
||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ use app\common\enum\PayEnum;
|
|||||||
use app\common\enum\YesNoEnum;
|
use app\common\enum\YesNoEnum;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\logic\CapitalFlowLogic;
|
use app\common\logic\CapitalFlowLogic;
|
||||||
|
use app\common\logic\StoreFinanceFlowLogic;
|
||||||
use app\common\model\merchant\Merchant;
|
use app\common\model\merchant\Merchant;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
@ -15,6 +16,7 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
|||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
@ -32,6 +34,7 @@ use Yansongda\Pay\Event\PayEnd;
|
|||||||
class OrderLogic extends BaseLogic
|
class OrderLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
public static $total;
|
public static $total;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取购物车商品信息
|
* @notes 获取购物车商品信息
|
||||||
* @param $params
|
* @param $params
|
||||||
@ -51,13 +54,13 @@ class OrderLogic extends BaseLogic
|
|||||||
/** 计算价格 */
|
/** 计算价格 */
|
||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
$find = StoreBranchProduct::where(['id' => $v['goods']])->field('store_name,image,unit,price')->find();
|
$find = StoreBranchProduct::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['price'], 2);//钱
|
$cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2);//钱
|
||||||
$cart_select[$k]['price'] = $find['price'];
|
$cart_select[$k]['price'] = $find['price'];
|
||||||
$cart_select[$k]['product_id'] = $find['goods'];
|
$cart_select[$k]['product_id'] = $find['goods'];
|
||||||
$cart_select[$k]['old_cart_id'] = implode(',',$cartId);
|
$cart_select[$k]['old_cart_id'] = implode(',', $cartId);
|
||||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
||||||
$cart_select[$k]['verify_code'] = $params['verify_code'];
|
$cart_select[$k]['verify_code'] = $params['verify_code'];
|
||||||
//理论上每笔都是拆分了
|
//理论上每笔都是拆分了
|
||||||
@ -65,7 +68,7 @@ class OrderLogic extends BaseLogic
|
|||||||
// $cart_select[$k]['imgs'] = $find['image'];
|
// $cart_select[$k]['imgs'] = $find['image'];
|
||||||
// $cart_select[$k]['unit_name'] = StoreProductUnit::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 = [
|
||||||
'add_time' => time(),
|
'add_time' => time(),
|
||||||
@ -76,8 +79,8 @@ class OrderLogic extends BaseLogic
|
|||||||
'total_num' => count($cart_select),//总数
|
'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),
|
||||||
'store_id'=>$params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'shipping_type'=>$params['shipping_type']//配送方式 1=快递 ,2=门店自提
|
'shipping_type' => $params['shipping_type']//配送方式 1=快递 ,2=门店自提
|
||||||
// 'delivery_msg'=>' 预计48小时发货 '
|
// 'delivery_msg'=>' 预计48小时发货 '
|
||||||
];
|
];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -96,7 +99,7 @@ class OrderLogic extends BaseLogic
|
|||||||
$verify_code = generateUniqueVerificationCode();
|
$verify_code = generateUniqueVerificationCode();
|
||||||
$params['verify_code'] = $verify_code;
|
$params['verify_code'] = $verify_code;
|
||||||
$orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params);
|
$orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params);
|
||||||
if(!$orderInfo){
|
if (!$orderInfo) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// `delivery_name`快递名称/送货人姓名',
|
// `delivery_name`快递名称/送货人姓名',
|
||||||
@ -104,21 +107,21 @@ class OrderLogic extends BaseLogic
|
|||||||
// `delivery_type` '发货类型',
|
// `delivery_type` '发货类型',
|
||||||
// `delivery_id'快递单号/手机号',
|
// `delivery_id'快递单号/手机号',
|
||||||
$_order = $orderInfo['order'];
|
$_order = $orderInfo['order'];
|
||||||
if($orderInfo['order']['shipping_type'] == 1){
|
if ($orderInfo['order']['shipping_type'] == 1) {
|
||||||
$_order['delivery_name'] = $params['delivery_name'];
|
$_order['delivery_name'] = $params['delivery_name'];
|
||||||
$_order['delivery_id'] = $params['delivery_id'];
|
$_order['delivery_id'] = $params['delivery_id'];
|
||||||
}
|
}
|
||||||
$_order['deduction_price'] = 0;
|
$_order['deduction_price'] = 0;
|
||||||
$_order['uid'] = request()->userId;
|
$_order['uid'] = request()->userId;
|
||||||
$user = User::where('id',\request()->userId)->find();
|
$user = User::where('id', \request()->userId)->find();
|
||||||
$_order['real_name'] = $user['real_name'];
|
$_order['real_name'] = $user['real_name'];
|
||||||
$_order['mobile'] = $user['mobile'];
|
$_order['mobile'] = $user['mobile'];
|
||||||
$_order['pay_type'] = $user['pay_type'];
|
$_order['pay_type'] = $user['pay_type'];
|
||||||
$_order['verify_code'] = $verify_code;
|
$_order['verify_code'] = $verify_code;
|
||||||
|
|
||||||
if($addressId>0){
|
if ($addressId > 0) {
|
||||||
$address=UserAddress::where(['address_id'=>$addressId,'uid'=>Request()->userId])->find();
|
$address = UserAddress::where(['address_id' => $addressId, 'uid' => Request()->userId])->find();
|
||||||
if($address){
|
if ($address) {
|
||||||
$_order['real_name'] = $address['real_name'];
|
$_order['real_name'] = $address['real_name'];
|
||||||
$_order['user_phone'] = $address['phone'];
|
$_order['user_phone'] = $address['phone'];
|
||||||
$_order['user_address'] = $address['detail'];
|
$_order['user_address'] = $address['detail'];
|
||||||
@ -137,13 +140,13 @@ class OrderLogic extends BaseLogic
|
|||||||
foreach ($goods_list as $k => $v) {
|
foreach ($goods_list as $k => $v) {
|
||||||
$goods_list[$k]['oid'] = $order->id;
|
$goods_list[$k]['oid'] = $order->id;
|
||||||
$goods_list[$k]['uid'] = request()->userId;
|
$goods_list[$k]['uid'] = request()->userId;
|
||||||
$goods_list[$k]['cart_id'] = implode(',',$cartId);
|
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||||
$goods_list[$k]['delivery_id'] = $params['store_id'];//商家id
|
$goods_list[$k]['delivery_id'] = $params['store_id'];//商家id
|
||||||
|
|
||||||
}
|
}
|
||||||
(new StoreOrderCartInfo())->saveAll($goods_list);
|
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||||
$where = ['is_pay' => 0, 'is_del' => 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;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -165,8 +168,8 @@ class OrderLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$mer_id = $user['merchant']['mer_id'];
|
$mer_id = $user['merchant']['mer_id'];
|
||||||
$where1 = ['paid' => 1,'is_opurchase'=>0];
|
$where1 = ['paid' => 1, 'is_opurchase' => 0];
|
||||||
$where1[] = ['pay_type','<>',9];
|
$where1[] = ['pay_type', '<>', 9];
|
||||||
|
|
||||||
$arrs = Cashierclass::where('merchant', $mer_id)->whereDay('create_time')->where($where1)->column('cart_id,id,address_id');
|
$arrs = Cashierclass::where('merchant', $mer_id)->whereDay('create_time')->where($where1)->column('cart_id,id,address_id');
|
||||||
// $order_id = Cashierclass::where('merchant', $mer_id)->whereDay('create_time')->where($where1)->column('id');
|
// $order_id = Cashierclass::where('merchant', $mer_id)->whereDay('create_time')->where($where1)->column('id');
|
||||||
@ -181,7 +184,7 @@ class OrderLogic extends BaseLogic
|
|||||||
// self::setError('请先设置配送地址');
|
// self::setError('请先设置配送地址');
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
$arr = explode(',',$v['cart_id']);
|
$arr = explode(',', $v['cart_id']);
|
||||||
foreach ($arr as $kk => $vv) {
|
foreach ($arr as $kk => $vv) {
|
||||||
$cart_arr[] = $vv;
|
$cart_arr[] = $vv;
|
||||||
}
|
}
|
||||||
@ -209,6 +212,7 @@ class OrderLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
return ['order' => $order, 'cart_list' => $cart_select];
|
return ['order' => $order, 'cart_list' => $cart_select];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建购货订单
|
* 创建购货订单
|
||||||
* @return Object|bool
|
* @return Object|bool
|
||||||
@ -256,6 +260,7 @@ class OrderLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取订单号
|
* @notes 获取订单号
|
||||||
* @param $type
|
* @param $type
|
||||||
@ -272,8 +277,6 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额订单支付
|
* 余额订单支付
|
||||||
* @param User $user
|
* @param User $user
|
||||||
@ -337,7 +340,7 @@ class OrderLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$goods_id = StoreOrderCartInfo::where('uid', Request()->userId)->page($params['page_no'])->limit(50)->column('product_id');
|
$goods_id = StoreOrderCartInfo::where('uid', Request()->userId)->page($params['page_no'])->limit(50)->column('product_id');
|
||||||
if(!$goods_id){
|
if (!$goods_id) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$goods_arr = array_unique($goods_id);
|
$goods_arr = array_unique($goods_id);
|
||||||
@ -349,53 +352,53 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function purchaseAgain($order_id){
|
public static function purchaseAgain($order_id)
|
||||||
$arr= StoreOrderCartInfo::where('oid',$order_id)->field('product_id,cart_num,staff_id')->select();
|
{
|
||||||
$data=[];
|
$arr = StoreOrderCartInfo::where('oid', $order_id)->field('product_id,cart_num,staff_id')->select();
|
||||||
foreach ($arr as $k=>$v){
|
$data = [];
|
||||||
$data[$k]['product_id']=$v['product_id'];
|
foreach ($arr as $k => $v) {
|
||||||
$unique = StoreProductAttrValue::where('product_id',$v['product_id'])->value('v');
|
$data[$k]['product_id'] = $v['product_id'];
|
||||||
$data[$k]['product_attr_unique']=$unique;
|
$unique = StoreProductAttrValue::where('product_id', $v['product_id'])->value('v');
|
||||||
$data[$k]['cart_num']=$v['cart_num'];
|
$data[$k]['product_attr_unique'] = $unique;
|
||||||
$data[$k]['type']='';
|
$data[$k]['cart_num'] = $v['cart_num'];
|
||||||
$data[$k]['uid']=Request()->userId;
|
$data[$k]['type'] = '';
|
||||||
$store_id = StoreProduct::where('id',$v['product_id'])->value('store_id');
|
$data[$k]['uid'] = Request()->userId;
|
||||||
$data[$k]['store_id']=$store_id;
|
$store_id = StoreProduct::where('id', $v['product_id'])->value('store_id');
|
||||||
$data[$k]['staff_id']=$v['staff_id'];
|
$data[$k]['store_id'] = $store_id;
|
||||||
$data[$k]['add_time']=time();
|
$data[$k]['staff_id'] = $v['staff_id'];
|
||||||
$data[$k]['combination_id']=0;
|
$data[$k]['add_time'] = time();
|
||||||
$data[$k]['seckill_id']=0;
|
$data[$k]['combination_id'] = 0;
|
||||||
$data[$k]['bargain_id']=0;
|
$data[$k]['seckill_id'] = 0;
|
||||||
$data[$k]['discount_id']=0;
|
$data[$k]['bargain_id'] = 0;
|
||||||
$data[$k]['status']=1;
|
$data[$k]['discount_id'] = 0;
|
||||||
$data[$k]['staff_id']=0;
|
$data[$k]['status'] = 1;
|
||||||
$data[$k]['is_new']=0;
|
$data[$k]['staff_id'] = 0;
|
||||||
$data[$k]['is_del']=0;
|
$data[$k]['is_new'] = 0;
|
||||||
$data[$k]['is_pay']=0;
|
$data[$k]['is_del'] = 0;
|
||||||
|
$data[$k]['is_pay'] = 0;
|
||||||
}
|
}
|
||||||
if($data){
|
if ($data) {
|
||||||
( new Cart())->saveAll($data);
|
(new Cart())->saveAll($data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
$find=StoreOrder::where($params)->findOrEmpty()->toArray();
|
$find = StoreOrder::where($params)->findOrEmpty()->toArray();
|
||||||
if($find){
|
if ($find) {
|
||||||
|
|
||||||
$find['goods_list']= StoreOrderCartInfo::where('oid',$find['id'])
|
$find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id'])
|
||||||
->with('goodsName')
|
->with('goodsName')
|
||||||
->field('product_id,cart_num nums')->select()->each(function($item){
|
->field('product_id,cart_num nums')->select()->each(function ($item) {
|
||||||
$item['msg']='预计48小时发货';
|
$item['msg'] = '预计48小时发货';
|
||||||
$item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name');
|
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||||
});
|
});
|
||||||
$merchant=Merchant::where('mer_id',$find['merchant'])->field('mer_id,uid,mer_name,service_phone,mer_address')->find();
|
$merchant = Merchant::where('mer_id', $find['merchant'])->field('mer_id,uid,mer_name,service_phone,mer_address')->find();
|
||||||
$merchant['real_name']=User::where('id',$merchant['uid'])->value('real_name');
|
$merchant['real_name'] = User::where('id', $merchant['uid'])->value('real_name');
|
||||||
$find['merchant_info']=$merchant;
|
$find['merchant_info'] = $merchant;
|
||||||
|
|
||||||
}
|
}
|
||||||
return $find;
|
return $find;
|
||||||
@ -414,34 +417,31 @@ class OrderLogic extends BaseLogic
|
|||||||
* @author: codeliu
|
* @author: codeliu
|
||||||
* @Time: 2024/6/3 22:42
|
* @Time: 2024/6/3 22:42
|
||||||
*/
|
*/
|
||||||
public static function writeOff($params,$uid): bool
|
public static function writeOff($params, $uid): bool
|
||||||
{
|
{
|
||||||
$data = StoreOrderCartInfo::where([
|
$data = StoreOrder::with('store')->where([
|
||||||
'oid'=>$params['order_id'],
|
'verify_code' => $params['verify_code'],
|
||||||
'verify_code'=>$params['verify_code'],
|
'uid' => $uid
|
||||||
'uid'=>$uid
|
])->find();
|
||||||
])->select()->toArray();
|
if (empty($data)) {
|
||||||
if (empty($data)){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$newArr = [];
|
StoreOrder::update([
|
||||||
$oid = [];
|
'status' => OrderEnum::RECEIVED_GOODS,
|
||||||
foreach ($data as $k =>$value){
|
'update_time' => time(),
|
||||||
$oid [] = $value['oid'];
|
], ['id' => $data['id']]);
|
||||||
$newArr[$k]['writeoff_time'] = time();
|
(new StoreOrderCartInfo())->update([
|
||||||
$newArr[$k]['id'] = $value['id'];
|
'writeoff_time' => time(),
|
||||||
$newArr[$k]['is_writeoff'] = YesNoEnum::YES;
|
'is_writeoff' => YesNoEnum::YES,
|
||||||
$newArr[$k]['update_time'] = time();
|
'update_time' => time(),
|
||||||
|
], ['oid' => $data['id']]);
|
||||||
|
$financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']);
|
||||||
|
if (!empty($financeFlow)) {
|
||||||
|
$capitalFlowLogic = new CapitalFlowLogic($data->store, 'store');
|
||||||
|
$capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']);
|
||||||
}
|
}
|
||||||
(new StoreOrderCartInfo())->saveAll($newArr);
|
|
||||||
$oidArr = array_values(array_unique($oid));
|
|
||||||
StoreOrder::whereIn('id',$oidArr)
|
|
||||||
->update([
|
|
||||||
'status' => OrderEnum::RECEIVED_GOODS,
|
|
||||||
'update_time' => time(),
|
|
||||||
]);
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -453,6 +453,4 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ class OrderValidate extends BaseValidate
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'order_id' => 'require|number',
|
|
||||||
'verify_code' => 'require',
|
'verify_code' => 'require',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ class OrderValidate extends BaseValidate
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $field = [
|
protected $field = [
|
||||||
'order_id' => '订单',
|
|
||||||
'verify_code' => '验证码',
|
'verify_code' => '验证码',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -40,9 +38,9 @@ class OrderValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneCheck()
|
public function sceneCheck()
|
||||||
{
|
{
|
||||||
return $this->only(['order_id','verify_code']);
|
return $this->only(['verify_code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,15 @@ class CapitalFlowLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
|
|
||||||
public $user;
|
public $user;
|
||||||
|
public $store;
|
||||||
|
|
||||||
public function __construct($user)
|
public function __construct($obj, $type = 'user')
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
if (isset($type)) {
|
||||||
|
$this->user = $obj;
|
||||||
|
} else {
|
||||||
|
$this->store = $obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,21 +82,22 @@ class CapitalFlowLogic extends BaseLogic
|
|||||||
* @param $mark
|
* @param $mark
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function merchantIncome($category, $linkType, $linkId, $amount, $mark = '')
|
public function storeIncome($category, $linkType, $linkId, $amount, $mark = '')
|
||||||
{
|
{
|
||||||
$model = new CapitalFlow();
|
$model = new CapitalFlow();
|
||||||
$model->mer_id = $this->user['mer_id'];
|
$model->store_id = $this->store['store_id'];
|
||||||
$model->category = $category;
|
$model->category = $category;
|
||||||
$model->link_type = $linkType;
|
$model->link_type = $linkType;
|
||||||
$model->link_id = $linkId;
|
$model->link_id = $linkId;
|
||||||
$model->amount = $amount;
|
$model->amount = $amount;
|
||||||
$model->before_balance = $this->user['mer_money'];
|
$model->before_balance = $this->store['balance'];
|
||||||
$model->balance = bcadd($this->user['mer_money'], $amount, 2);
|
$model->balance = bcadd($this->store['balance'], $amount, 2);
|
||||||
$model->create_time = date('Y-m-d H:i:s');
|
$model->create_time = date('Y-m-d H:i:s');
|
||||||
$model->type = 'in';
|
$model->type = 'in';
|
||||||
$model->title = $this->getTitle($category, $amount);
|
$model->title = $this->getTitle($category, $amount);
|
||||||
$model->mark = empty($mark) ? $model->title : $mark;
|
$model->mark = empty($mark) ? $model->title : $mark;
|
||||||
$model->save();
|
$model->save();
|
||||||
|
$this->store->update(['balance' => $model->balance], ['id' => $this->store['id']]);
|
||||||
return $model->id;
|
return $model->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,22 +110,23 @@ class CapitalFlowLogic extends BaseLogic
|
|||||||
* @param $mark
|
* @param $mark
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function merchantExpense($category, $linkType, $linkId, $amount, $mark = '')
|
public function storeExpense($category, $linkType, $linkId, $amount, $mark = '')
|
||||||
{
|
{
|
||||||
$model = new CapitalFlow();
|
$model = new CapitalFlow();
|
||||||
$model->mer_id = $this->user['mer_id'];
|
$model->store_id = $this->store['store_id'];
|
||||||
$model->uid = $this->user['uid'];
|
$model->uid = 0;
|
||||||
$model->category = $category;
|
$model->category = $category;
|
||||||
$model->link_type = $linkType;
|
$model->link_type = $linkType;
|
||||||
$model->link_id = $linkId;
|
$model->link_id = $linkId;
|
||||||
$model->amount = $amount;
|
$model->amount = $amount;
|
||||||
$model->before_balance = $this->user['mer_money'];
|
$model->before_balance = $this->store['balance'];
|
||||||
$model->balance = bcsub($this->user['mer_money'], $amount, 2);
|
$model->balance = bcsub($this->store['balance'], $amount, 2);
|
||||||
$model->create_time = date('Y-m-d H:i:s');
|
$model->create_time = date('Y-m-d H:i:s');
|
||||||
$model->type = 'out';
|
$model->type = 'out';
|
||||||
$model->title = $this->getTitle($category, $amount);
|
$model->title = $this->getTitle($category, $amount);
|
||||||
$model->mark = empty($mark) ? $model->title : $mark;
|
$model->mark = empty($mark) ? $model->title : $mark;
|
||||||
$model->save();
|
$model->save();
|
||||||
|
$this->store->update(['balance' => $model->balance], ['id' => $this->store['id']]);
|
||||||
return $model->id;
|
return $model->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,15 +135,15 @@ class CapitalFlowLogic extends BaseLogic
|
|||||||
switch ($category) {
|
switch ($category) {
|
||||||
case 'user_balance_recharge':
|
case 'user_balance_recharge':
|
||||||
return "用户充值{$amount}元";
|
return "用户充值{$amount}元";
|
||||||
case 'merchant_margin':
|
case 'store_margin':
|
||||||
return "店铺自动扣除保证金{$amount}元";
|
return "店铺自动扣除保证金{$amount}元";
|
||||||
case 'merchant_order_income':
|
case 'store_order_income':
|
||||||
return "店铺订单收入{$amount}元";
|
return "店铺订单收入{$amount}元";
|
||||||
case 'user_order_refund':
|
case 'user_order_refund':
|
||||||
return "用户订单退款{$amount}元";
|
return "用户订单退款{$amount}元";
|
||||||
case 'merchant_order_refund':
|
case 'store_order_refund':
|
||||||
return "店铺订单退款{$amount}元";
|
return "店铺订单退款{$amount}元";
|
||||||
case 'merchant_margin_refund':
|
case 'store_margin_refund':
|
||||||
return "店铺退还保证金{$amount}元";
|
return "店铺退还保证金{$amount}元";
|
||||||
case 'user_order_promotion':
|
case 'user_order_promotion':
|
||||||
return "订单推广佣金{$amount}元";
|
return "订单推广佣金{$amount}元";
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\common\logic;
|
namespace app\common\logic;
|
||||||
|
|
||||||
|
use app\common\enum\OrderEnum;
|
||||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||||
|
|
||||||
class StoreFinanceFlowLogic extends BaseLogic
|
class StoreFinanceFlowLogic extends BaseLogic
|
||||||
@ -72,4 +73,13 @@ class StoreFinanceFlowLogic extends BaseLogic
|
|||||||
return 'fn' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
|
return 'fn' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStoreOrder($orderId, $storeId = 0, $status = 0)
|
||||||
|
{
|
||||||
|
return StoreFinanceFlow::where('order_id', $orderId)
|
||||||
|
->where('store_id', $storeId)
|
||||||
|
->where('status', $status)
|
||||||
|
->where('financial_type', OrderEnum::MERCHANT_ORDER_OBTAINS)
|
||||||
|
->find();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace app\common\model\store_order;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -18,5 +19,9 @@ class StoreOrder extends BaseModel
|
|||||||
protected $name = 'store_order';
|
protected $name = 'store_order';
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
public function store()
|
||||||
}
|
{
|
||||||
|
return $this->hasOne(SystemStore::class, 'id','store_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -80,6 +80,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
ApiDoc\url('/store/store_product/storeProduct/edit'),
|
ApiDoc\url('/store/store_product/storeProduct/edit'),
|
||||||
ApiDoc\Method('POST'),
|
ApiDoc\Method('POST'),
|
||||||
ApiDoc\NotHeaders(),
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Query(name: "id", type: "int", require: true, desc: "id"),
|
||||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||||
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
||||||
@ -108,6 +109,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
ApiDoc\url('/store/store_product/storeProduct/delete'),
|
ApiDoc\url('/store/store_product/storeProduct/delete'),
|
||||||
ApiDoc\Method('POST'),
|
ApiDoc\Method('POST'),
|
||||||
ApiDoc\NotHeaders(),
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Param(name: "id", type: "int", require: true, desc: "id"),
|
||||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||||
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
||||||
@ -133,6 +135,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
ApiDoc\url('/store/store_product/storeProduct/detail'),
|
ApiDoc\url('/store/store_product/storeProduct/detail'),
|
||||||
ApiDoc\Method('GET'),
|
ApiDoc\Method('GET'),
|
||||||
ApiDoc\NotHeaders(),
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Query(name: "id", type: "int", require: true, desc: "id"),
|
||||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||||
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
||||||
@ -158,6 +161,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
ApiDoc\url('/store/store_product/storeProduct/status'),
|
ApiDoc\url('/store/store_product/storeProduct/status'),
|
||||||
ApiDoc\Method('POST'),
|
ApiDoc\Method('POST'),
|
||||||
ApiDoc\NotHeaders(),
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Param(name: "id", type: "int", require: true, desc: "id"),
|
||||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
]
|
]
|
||||||
@ -165,7 +169,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = (new StoreProductValidate())->post()->goCheck('detail');
|
$params = (new StoreProductValidate())->post()->goCheck('detail');
|
||||||
StoreBranchProductLogic::status($params);
|
StoreBranchProductLogic::status($params);
|
||||||
return $this->data([]);
|
return $this->success('操作成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[
|
#[
|
||||||
@ -183,7 +187,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = (new StoreProductValidate())->post()->goCheck('stock');
|
$params = (new StoreProductValidate())->post()->goCheck('stock');
|
||||||
StoreBranchProductLogic::stock($params);
|
StoreBranchProductLogic::stock($params);
|
||||||
return $this->data([]);
|
return $this->success('操作成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user