diff --git a/.gitignore b/.gitignore index 575640412..ee1734d91 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .env /tests/tmp /tests/.phpunit.result.cache -public/uploads \ No newline at end of file +public/uploads +public/image \ No newline at end of file diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index a26b5bf96..72b3ad1ef 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -49,8 +49,8 @@ class StoreProductLogic extends BaseLogic 'purchase' => $params['purchase'], 'rose' => $params['rose'], 'is_return' => $params['is_return'], - 'swap' => $params['swap']??0, - 'batch' => $params['batch']??0, + 'swap' => $params['swap'] ?? 0, + 'batch' => $params['batch'] ?? 0, ]; // if ($params['rose'] > 0) { // $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()]); } - 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()]); } - } } @@ -151,38 +150,38 @@ class StoreProductLogic extends BaseLogic 'vip_price' => $params['vip_price'], 'cost' => $params['cost'], 'batch' => $params['batch'], - 'swap' => $params['swap']??0, + 'swap' => $params['swap'] ?? 0, - ]; + ]; - StoreProduct::where('id', $params['id'])->update($data); - $old_cate = StoreBranchProduct::where('product_id', $params['id'])->field('cate_id,store_id') - ->select(); - - // 获取分类ID - foreach ($old_cate as $vv) { - $related_data = Db::name('store_product_cate')->where('cate_id', $vv['cate_id'])->select(); - //删除之前的分类 - foreach ($related_data as $value) { - if ($value['count'] == 1) { - self::deleteRelatedData($value['cate_id']); - } elseif ($value['count'] > 1) { - self::decreaseCount($value['cate_id']); + StoreProduct::where('id', $params['id'])->update($data); + $old_cate = StoreBranchProduct::where('product_id', $params['id'])->field('cate_id,store_id') + ->select(); + // 获取分类ID + foreach ($old_cate as $vv) { + $related_data = Db::name('store_product_cate')->where('cate_id', $vv['cate_id'])->select(); + //删除之前的分类 + foreach ($related_data as $value) { + if ($value['count'] == 1) { + self::deleteRelatedData($value['cate_id']); + } elseif ($value['count'] > 1) { + 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([ - 'price' => $params['price'], 'vip_price' => $params['vip_price'], - 'cost' => $params['cost'], 'cate_id' => $params['cate_id'] - ]); + //修改 + StoreBranchProduct::where('product_id', $params['id'])->update([ + 'price' => $params['price'], 'vip_price' => $params['vip_price'], + 'cost' => $params['cost'], 'cate_id' => $params['cate_id'], + 'batch'=>$params['batch'] + ]); Db::commit(); - return true; + return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); diff --git a/app/api/controller/user/UserRechargeController.php b/app/api/controller/user/UserRechargeController.php index 6ca86becf..ba97d6a54 100644 --- a/app/api/controller/user/UserRechargeController.php +++ b/app/api/controller/user/UserRechargeController.php @@ -6,7 +6,7 @@ use app\api\logic\user\UserFeedbackLogic; use app\admin\validate\user\UserFeedbackValidate; use app\api\controller\BaseApiController; - +use app\api\lists\user\UserRechargeLists; class UserRechargeController extends BaseApiController { @@ -19,6 +19,6 @@ */ public function lists() { - return $this->dataLists(new UserFeedbackLists()); + return $this->dataLists(new UserRechargeLists()); } } diff --git a/app/api/lists/user/UserRechargeLists.php b/app/api/lists/user/UserRechargeLists.php index 482cf821c..2090f6420 100644 --- a/app/api/lists/user/UserRechargeLists.php +++ b/app/api/lists/user/UserRechargeLists.php @@ -42,8 +42,7 @@ use app\common\model\user_recharge\UserRecharge; ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ - $user = User::field('nickname')->where('id',$data['uid'])->findOrEmpty(); - $data['user_name'] = !$user->isEmpty() ? $user['nickname'] : ''; + $data['real_name'] =User::where('id',$data['uid'])->value('real_name'); }) ->toArray(); } @@ -57,7 +56,7 @@ use app\common\model\user_recharge\UserRecharge; */ public function count(): int { - return UserFeedback::where($this->searchWhere)->count(); + return UserRecharge::where($this->searchWhere)->count(); } } \ No newline at end of file diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index d87393fd9..2a6503732 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -197,7 +197,7 @@ class OrderLogic extends BaseLogic $generator = new BarcodeGeneratorPNG(); $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); $findPath = '/image/barcode/'.time().'.png'; - $savePath = 'public'.$findPath; + $savePath = public_path().$findPath; file_put_contents($savePath, $barcode); $_order['verify_img'] = $findPath; Db::startTrans(); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index e51603b15..49e30112e 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -80,7 +80,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']); // 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' => '您有一笔新的订单']); } @@ -97,7 +97,7 @@ class PayNotifyLogic extends BaseLogic public static function purchase_funds($orderSn, $extra = []) { $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']) { throw new \Exception('采购款不足'); } @@ -114,7 +114,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price']); // 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' => '您有一笔新的订单']); } @@ -154,11 +154,11 @@ class PayNotifyLogic extends BaseLogic if ($order->pay_type == 9) { $extra['create_time'] = $order['create_time']; 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 { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); // 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) { 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) { $extra['create_time'] = $order['create_time']; 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 { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } - Redis::send('push-platform-print', ['id' => $order['id']]); return true; } diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index de727787f..206e34efc 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -15,7 +15,12 @@ use app\common\logic\PayNotifyLogic; use app\common\logic\SystemStoreStaffLogic; use app\store\controller\BaseAdminController; 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_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\store\validate\store_order\StoreOrderValidate; use support\Log; @@ -396,8 +401,35 @@ class StoreOrderController extends BaseAdminController }else{ 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); } }