M2b3c4erge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev

This commit is contained in:
liu 2024-06-17 15:30:23 +08:00
commit d6f0446dce
7 changed files with 73 additions and 41 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@
.env .env
/tests/tmp /tests/tmp
/tests/.phpunit.result.cache /tests/.phpunit.result.cache
public/uploads public/uploads
public/image

View File

@ -49,8 +49,8 @@ class StoreProductLogic extends BaseLogic
'purchase' => $params['purchase'], 'purchase' => $params['purchase'],
'rose' => $params['rose'], 'rose' => $params['rose'],
'is_return' => $params['is_return'], 'is_return' => $params['is_return'],
'swap' => $params['swap']??0, 'swap' => $params['swap'] ?? 0,
'batch' => $params['batch']??0, 'batch' => $params['batch'] ?? 0,
]; ];
// if ($params['rose'] > 0) { // if ($params['rose'] > 0) {
// $rose_price = bcmul($params['cost'], $params['rose'], 2); // $rose_price = bcmul($params['cost'], $params['rose'], 2);
@ -106,10 +106,9 @@ class StoreProductLogic extends BaseLogic
StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]); StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]);
} }
if($item['pid'] == 0 && in_array($item['count'],[0,1])){ if ($item['pid'] == 0 && in_array($item['count'], [0, 1])) {
StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]); StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]);
} }
} }
} }
@ -151,38 +150,38 @@ class StoreProductLogic extends BaseLogic
'vip_price' => $params['vip_price'], 'vip_price' => $params['vip_price'],
'cost' => $params['cost'], 'cost' => $params['cost'],
'batch' => $params['batch'], 'batch' => $params['batch'],
'swap' => $params['swap']??0, 'swap' => $params['swap'] ?? 0,
]; ];
StoreProduct::where('id', $params['id'])->update($data); StoreProduct::where('id', $params['id'])->update($data);
$old_cate = StoreBranchProduct::where('product_id', $params['id'])->field('cate_id,store_id') $old_cate = StoreBranchProduct::where('product_id', $params['id'])->field('cate_id,store_id')
->select(); ->select();
// 获取分类ID
// 获取分类ID foreach ($old_cate as $vv) {
foreach ($old_cate as $vv) { $related_data = Db::name('store_product_cate')->where('cate_id', $vv['cate_id'])->select();
$related_data = Db::name('store_product_cate')->where('cate_id', $vv['cate_id'])->select(); //删除之前的分类
//删除之前的分类 foreach ($related_data as $value) {
foreach ($related_data as $value) { if ($value['count'] == 1) {
if ($value['count'] == 1) { self::deleteRelatedData($value['cate_id']);
self::deleteRelatedData($value['cate_id']); } elseif ($value['count'] > 1) {
} elseif ($value['count'] > 1) { self::decreaseCount($value['cate_id']);
self::decreaseCount($value['cate_id']); }
//新增对应的分类
self::updateGoodsclass($params['cate_id'], $value['store_id']);
} }
//新增对应的分类
self::updateGoodsclass($params['cate_id'], $value['store_id']);
} }
}
//修改 //修改
StoreBranchProduct::where('product_id', $params['id'])->update([ StoreBranchProduct::where('product_id', $params['id'])->update([
'price' => $params['price'], 'vip_price' => $params['vip_price'], 'price' => $params['price'], 'vip_price' => $params['vip_price'],
'cost' => $params['cost'], 'cate_id' => $params['cate_id'] 'cost' => $params['cost'], 'cate_id' => $params['cate_id'],
]); 'batch'=>$params['batch']
]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollback(); Db::rollback();
self::setError($e->getMessage()); self::setError($e->getMessage());

View File

@ -6,7 +6,7 @@
use app\api\logic\user\UserFeedbackLogic; use app\api\logic\user\UserFeedbackLogic;
use app\admin\validate\user\UserFeedbackValidate; use app\admin\validate\user\UserFeedbackValidate;
use app\api\controller\BaseApiController; use app\api\controller\BaseApiController;
use app\api\lists\user\UserRechargeLists;
class UserRechargeController extends BaseApiController class UserRechargeController extends BaseApiController
{ {
@ -19,6 +19,6 @@
*/ */
public function lists() public function lists()
{ {
return $this->dataLists(new UserFeedbackLists()); return $this->dataLists(new UserRechargeLists());
} }
} }

View File

@ -42,8 +42,7 @@ use app\common\model\user_recharge\UserRecharge;
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function($data){ ->select()->each(function($data){
$user = User::field('nickname')->where('id',$data['uid'])->findOrEmpty(); $data['real_name'] =User::where('id',$data['uid'])->value('real_name');
$data['user_name'] = !$user->isEmpty() ? $user['nickname'] : '';
}) })
->toArray(); ->toArray();
} }
@ -57,7 +56,7 @@ use app\common\model\user_recharge\UserRecharge;
*/ */
public function count(): int public function count(): int
{ {
return UserFeedback::where($this->searchWhere)->count(); return UserRecharge::where($this->searchWhere)->count();
} }
} }

View File

@ -197,7 +197,7 @@ class OrderLogic extends BaseLogic
$generator = new BarcodeGeneratorPNG(); $generator = new BarcodeGeneratorPNG();
$barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128);
$findPath = '/image/barcode/'.time().'.png'; $findPath = '/image/barcode/'.time().'.png';
$savePath = 'public'.$findPath; $savePath = public_path().$findPath;
file_put_contents($savePath, $barcode); file_put_contents($savePath, $barcode);
$_order['verify_img'] = $findPath; $_order['verify_img'] = $findPath;
Db::startTrans(); Db::startTrans();

View File

@ -80,7 +80,7 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']); $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']);
// self::afterPay($order); // self::afterPay($order);
Redis::send('push-platform-print', ['id' => $order['id']], 60); // Redis::send('push-platform-print', ['id' => $order['id']], 60);
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
} }
@ -97,7 +97,7 @@ class PayNotifyLogic extends BaseLogic
public static function purchase_funds($orderSn, $extra = []) public static function purchase_funds($orderSn, $extra = [])
{ {
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
$user = User::where('id', $extra['uid'])->find(); $user = User::where('id', $order['uid'])->find();
if ($user['purchase_funds'] < $order['pay_price']) { if ($user['purchase_funds'] < $order['pay_price']) {
throw new \Exception('采购款不足'); throw new \Exception('采购款不足');
} }
@ -114,7 +114,7 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price']); $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price']);
// self::afterPay($order); // self::afterPay($order);
Redis::send('push-platform-print', ['id' => $order['id']], 60); // Redis::send('push-platform-print', ['id' => $order['id']], 60);
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
} }
@ -154,11 +154,11 @@ 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['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
Redis::send('push-platform-print', ['id' => $order['id']]);
} else { } else {
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]); // Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
} }
Redis::send('push-platform-print', ['id' => $order['id']]);
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5); Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5);
} }
@ -281,10 +281,11 @@ 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['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
Redis::send('push-platform-print', ['id' => $order['id']]);
} else { } else {
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
} }
Redis::send('push-platform-print', ['id' => $order['id']]);
return true; return true;
} }

View File

@ -15,7 +15,12 @@ use app\common\logic\PayNotifyLogic;
use app\common\logic\SystemStoreStaffLogic; use app\common\logic\SystemStoreStaffLogic;
use app\store\controller\BaseAdminController; use app\store\controller\BaseAdminController;
use app\common\logic\store_order\StoreOrderLogic; use app\common\logic\store_order\StoreOrderLogic;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_order\StoreOrder; use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user_recharge\UserRecharge; use app\common\model\user_recharge\UserRecharge;
use app\store\validate\store_order\StoreOrderValidate; use app\store\validate\store_order\StoreOrderValidate;
use support\Log; use support\Log;
@ -396,8 +401,35 @@ class StoreOrderController extends BaseAdminController
}else{ }else{
return $this->fail('发送失败'); return $this->fail('发送失败');
} }
}
/**
* 订单打印
*/
public function print(){
$id=$this->request->get('id');
$find = StoreOrder::where('id', $id)->find();
if ($find) {
$merchant = SystemStore::where('id', $find['store_id'])->field('name,phone')->find();
$mer_user_info = SystemStoreStaff::where('store_id', $find['store_id'])->where('is_admin',1)->field('staff_name,phone')->find();
$user = User::where('id', $find['uid'])->field('nickname,mobile')->find();
$find['system_store_name'] = $merchant['name'];
$find['pay_type_name'] = PayEnum::getPaySceneDesc($find['pay_type']);
$find['system_store_phone'] = $merchant['phone'];
$find['staff_name'] = $mer_user_info['staff_name'];
$find['staff_phone'] = $mer_user_info['phone'];
$find['nickname'] = $user['nickname']??'';
$find['user_mobile'] = $user['mobile']??'';
$find['info'] = StoreOrderCartInfo::where('oid', $find['id'])->field('store_id,product_id,cart_num,cart_info')->select()->each(function ($item) {
$goods = StoreBranchProduct::where(['store_id'=>$item['store_id'],'product_id'=>$item['product_id']])->field('store_name,unit')->find();
$item['unit_name'] = StoreProductUnit::where('id', $goods['unit'])->value('name');
$item['store_name'] = $goods['store_name'];
$item['total_price'] = $item['cart_info']['total_price'];
$item['price'] = $item['cart_info']['price'];
return $item;
});
}
return $this->success('获取成功', $find);
} }
} }