From 3a82a0f435716545d1abab236f19ad929ad5bdf6 Mon Sep 17 00:00:00 2001
From: mkm <727897186@qq.com>
Date: Mon, 3 Jun 2024 16:16:35 +0800
Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=B3=BB?=
 =?UTF-8?q?=E7=BB=9F=E5=95=86=E5=BA=97=E9=80=BB=E8=BE=91=E4=BB=A5=E5=A4=84?=
 =?UTF-8?q?=E7=90=86=E7=AE=A1=E7=90=86=E5=91=98=E5=AF=86=E7=A0=81=E5=92=8C?=
 =?UTF-8?q?=E5=91=98=E5=B7=A5=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../logic/system_store/SystemStoreLogic.php   | 47 ++++++++++++-------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/app/admin/logic/system_store/SystemStoreLogic.php b/app/admin/logic/system_store/SystemStoreLogic.php
index 464b334b4..c07cc136f 100644
--- a/app/admin/logic/system_store/SystemStoreLogic.php
+++ b/app/admin/logic/system_store/SystemStoreLogic.php
@@ -30,8 +30,8 @@ class SystemStoreLogic extends BaseLogic
         Db::startTrans();
         try {
             $passwordSalt = Config::get('project.unique_identification');
-            $password=create_password($params['password'], $passwordSalt);
-            $store=SystemStore::create([
+            $password = create_password($params['password'], $passwordSalt);
+            $store = SystemStore::create([
                 'name' => $params['name'],
                 'introduction' => $params['introduction'],
                 'phone' => $params['phone'],
@@ -47,15 +47,15 @@ class SystemStoreLogic extends BaseLogic
                 'area' => $params['area_code'],
                 'street' => $params['street_code'],
             ]);
-            $taff=[
-                'store_id'=>$store['id'],
-                'account'=>$params['phone'],
-                'pwd'=>$password,
-                'avatar'=>$params['image'],
-                'staff_name'=>$params['name'],
-                'phone'=>$params['phone'],
-                'is_admin'=>1,
-                'status'=>1,
+            $taff = [
+                'store_id' => $store['id'],
+                'account' => $params['phone'],
+                'pwd' => $password,
+                'avatar' => $params['image'],
+                'staff_name' => $params['name'],
+                'phone' => $params['phone'],
+                'is_admin' => 1,
+                'status' => 1,
 
             ];
             SystemStoreStaff::create($taff);
@@ -80,16 +80,31 @@ class SystemStoreLogic extends BaseLogic
     {
         Db::startTrans();
         try {
-            SystemStore::where('id', $params['id'])->update([
+            $store = SystemStore::where('id',$params['id'])->update([
                 'name' => $params['name'],
                 'introduction' => $params['introduction'],
-                'phone' => $params['phone'],
                 'detailed_address' => $params['detailed_address'],
                 'image' => $params['image'],
-                'latitude' => $params['latitude'],
+                'is_show' => $params['is_show'],
                 'longitude' => $params['longitude'],
-                'is_show' => $params['is_show']
+                'latitude' => $params['latitude'],
+                'day_start' => $params['day_start'],
+                'day_end' => $params['day_end'],
+                'province' => $params['province_code'],
+                'city' => $params['city_code'],
+                'area' => $params['area_code'],
+                'street' => $params['street_code'],
             ]);
+            if($params['password']!=''){
+                $passwordSalt = Config::get('project.unique_identification');
+                $password = create_password($params['password'], $passwordSalt);
+                $taff = [
+                    'pwd' => $password,
+                    'avatar' => $params['image'],
+                    'staff_name' => $params['name'],
+                ];
+                SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->update($taff);
+            }
 
             Db::commit();
             return true;
@@ -125,4 +140,4 @@ class SystemStoreLogic extends BaseLogic
     {
         return SystemStore::findOrEmpty($params['id'])->toArray();
     }
-}
\ No newline at end of file
+}

From fa84702c3b5460e272bf674fd953564f80870b23 Mon Sep 17 00:00:00 2001
From: mkm <727897186@qq.com>
Date: Mon, 3 Jun 2024 16:43:43 +0800
Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?=
 =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=E7=9B=B8=E5=85=B3=E7=9A=84?=
 =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E5=92=8C=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2?=
 =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0=E4=BA=86?=
 =?UTF-8?q?=E5=95=86=E5=93=81=E8=AE=A2=E5=8D=95=E5=92=8C=E9=97=A8=E5=BA=97?=
 =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=9B=B8=E5=85=B3=E7=9A=84=E9=80=BB=E8=BE=91?=
 =?UTF-8?q?=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../StoreFinanceFlowController.php            | 47 -------------------
 .../StoreFinanceFlowLists.php                 | 27 +++++++++--
 .../lists/store_order/StoreOrderLists.php     |  6 ++-
 .../logic/store_product/StoreProductLogic.php |  1 +
 app/common/enum/PayEnum.php                   | 29 +++++++-----
 5 files changed, 44 insertions(+), 66 deletions(-)

diff --git a/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php b/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php
index f005e2e03..a5bae6f02 100644
--- a/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php
+++ b/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php
@@ -30,53 +30,6 @@ class StoreFinanceFlowController extends BaseAdminController
     }
 
 
-    /**
-     * @notes 添加门店流水
-     * @return \think\response\Json
-     * @author admin
-     * @date 2024/05/31 16:56
-     */
-    public function add()
-    {
-        $params = (new StoreFinanceFlowValidate())->post()->goCheck('add');
-        $result = StoreFinanceFlowLogic::add($params);
-        if (true === $result) {
-            return $this->success('添加成功', [], 1, 1);
-        }
-        return $this->fail(StoreFinanceFlowLogic::getError());
-    }
-
-
-    /**
-     * @notes 编辑门店流水
-     * @return \think\response\Json
-     * @author admin
-     * @date 2024/05/31 16:56
-     */
-    public function edit()
-    {
-        $params = (new StoreFinanceFlowValidate())->post()->goCheck('edit');
-        $result = StoreFinanceFlowLogic::edit($params);
-        if (true === $result) {
-            return $this->success('编辑成功', [], 1, 1);
-        }
-        return $this->fail(StoreFinanceFlowLogic::getError());
-    }
-
-
-    /**
-     * @notes 删除门店流水
-     * @return \think\response\Json
-     * @author admin
-     * @date 2024/05/31 16:56
-     */
-    public function delete()
-    {
-        $params = (new StoreFinanceFlowValidate())->post()->goCheck('delete');
-        StoreFinanceFlowLogic::delete($params);
-        return $this->success('删除成功', [], 1, 1);
-    }
-
 
     /**
      * @notes 获取门店流水详情
diff --git a/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php b/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php
index 00c75b096..7dfa79216 100644
--- a/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php
+++ b/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php
@@ -4,9 +4,13 @@ namespace app\admin\lists\store_finance_flow;
 
 
 use app\admin\lists\BaseAdminDataLists;
+use app\common\enum\OrderEnum;
+use app\common\enum\PayEnum;
 use app\common\model\store_finance_flow\StoreFinanceFlow;
 use app\common\lists\ListsSearchInterface;
-
+use app\common\model\financial_record\FinancialRecord;
+use app\common\model\system_store\SystemStoreStaff;
+use app\common\model\user\User;
 
 /**
  * 门店流水列表
@@ -26,7 +30,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
     public function setSearch(): array
     {
         return [
-            '=' => ['store_id', 'uid', 'create_time'],
+            '=' => ['store_id', 'user_id', 'create_time'],
         ];
     }
 
@@ -42,11 +46,24 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
      */
     public function lists(): array
     {
-        return StoreFinanceFlow::where($this->searchWhere)
-            ->field(['id', 'uid', 'staff_id', 'order_id', 'link_id', 'type', 'pay_type', 'remark', 'trade_time'])
+        return FinancialRecord::where($this->searchWhere)
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
-            ->select()
+            ->select()->each(function ($item) {
+                if($item['user_id']<=0){
+                    $item['nickname']='游客';
+                }else{
+                    $item['nickname']=User::where('id',$item['user_id'])->value('nickname');
+                }
+                if($item['financial_pm']==0){
+                    $item['number']='-'.$item['number'];
+                }else{
+                    $item['number']='+'.$item['number'];
+                }
+                $item['staff_name']=SystemStoreStaff::where('id',$item['staff_id'])->value('staff_name');
+                $item['pay_type_name']=PayEnum::getPaySceneDesc($item['pay_type']);
+                $item['financial_type_name']=OrderEnum::getFinancialType($item['financial_type']);
+            })
             ->toArray();
     }
 
diff --git a/app/admin/lists/store_order/StoreOrderLists.php b/app/admin/lists/store_order/StoreOrderLists.php
index 4fed49152..e1e33cacb 100644
--- a/app/admin/lists/store_order/StoreOrderLists.php
+++ b/app/admin/lists/store_order/StoreOrderLists.php
@@ -4,6 +4,7 @@ namespace app\admin\lists\store_order;
 
 
 use app\admin\lists\BaseAdminDataLists;
+use app\common\enum\PayEnum;
 use app\common\model\store_order\StoreOrder;
 use app\common\lists\ListsSearchInterface;
 
@@ -46,7 +47,10 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
             ->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
-            ->select()
+            ->select()->each(function($item){
+                $item['pay_type_name']=PayEnum::getPaySceneDesc($item['pay_type']);
+                return $item;
+            })
             ->toArray();
     }
 
diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php
index a74942a9b..5c3c64476 100644
--- a/app/admin/logic/store_product/StoreProductLogic.php
+++ b/app/admin/logic/store_product/StoreProductLogic.php
@@ -212,6 +212,7 @@ class StoreProductLogic extends BaseLogic
                     'bar_code' => $find['bar_code'],
                     'cate_id' => $find['cate_id'],
                     'price' => $find['price'],
+                    'unit' => $find['unit'],
                     'store_id' => $store_id,
                     'sales' => 0,
                     'stock' => $stock,
diff --git a/app/common/enum/PayEnum.php b/app/common/enum/PayEnum.php
index 5926c3129..ad9523f06 100644
--- a/app/common/enum/PayEnum.php
+++ b/app/common/enum/PayEnum.php
@@ -56,14 +56,6 @@ class PayEnum
 
 
 
-    //支付场景
-    const SCENE_H5 = 1; //H5
-    const SCENE_OA = 2; //微信公众号
-    const SCENE_MNP = 3; //微信小程序
-    const SCENE_APP = 4; //APP
-    const SCENE_PC = 5; //PC商城
-
-
     /**
      * @notes 获取支付类型
      * @param bool $value
@@ -116,11 +108,22 @@ class PayEnum
     public static function getPaySceneDesc($value = true)
     {
         $data = [
-            self::SCENE_H5 => 'H5',
-            self::SCENE_OA => '微信公众号',
-            self::SCENE_MNP => '微信小程序',
-            self::SCENE_APP => 'APP',
-            self::SCENE_PC => 'PC',
+            self::WECHAT_PAY_H5 => '微信H5',
+            self::WECHAT_PAY_JSAPI => '微信JSAPI',
+            self::WECHAT_PAY_MINI => '微信小程序',
+            self::WECHAT_PAY_APP => '微信APP',
+            self::ALIPAY_H5 => '支付宝H5',
+            self::ALIPAY_MINI => '支付宝小程序',
+            self::ALIPAY_APP => '支付宝APP',
+            self::GOODS_FIRST_PAYMENT_LATER => '货到付款',
+            self::CORPORATE_TRANSFER => '企业转账', 
+            self::CASH_PAY => '现金支付', 
+            self::WECHAT_PAY_QRCODE => '微信二维码',
+            self::WECHAT_PAY_BARCODE => '微信条码',
+            self::ALIPAY_QRCODE => '支付宝二维码',
+            self::ALIPAY_BARCODE => '支付宝条码',
+            self::BALANCE_PAY => '余额支付',
+
         ];
         if ($value === true) {
             return $data;

From 3eb1fb30b833201403e9e7f1c1ac1b624adcca4a Mon Sep 17 00:00:00 2001
From: liu <1873441552@qq.com>
Date: Mon, 3 Jun 2024 16:59:57 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=9F=A5=E8=AF=A2?=
 =?UTF-8?q?=E5=92=8C=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E6=9B=B4=E6=96=B0?=
 =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/api/lists/order/OrderList.php             |  8 ++--
 app/api/lists/product/ProductLists.php        | 37 ++++---------------
 .../StoreBranchProduct.php                    |  5 +++
 .../StoreOrderCartInfo.php                    |  4 +-
 4 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php
index 486ee9b50..cbefa413e 100644
--- a/app/api/lists/order/OrderList.php
+++ b/app/api/lists/order/OrderList.php
@@ -8,6 +8,8 @@ use app\common\lists\ListsSearchInterface;
 use app\common\model\goods\Goods;
 use app\common\model\retail\Cashierclass;
 use app\common\model\retail\Cashierinfo;
+use app\common\model\store_order\StoreOrder;
+use app\common\model\store_order_cart_info\StoreOrderCartInfo;
 
 /**
  * 零售订单列表
@@ -45,12 +47,12 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
     {
         $userId=$this->request->userId;
         if(!$userId) return [];
-        return Cashierclass::where($this->searchWhere)->where('uid',$userId)
+        return StoreOrder::where($this->searchWhere)->where('uid',$userId)
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
             ->each(function($item){
-                $item['goods_list']=Cashierinfo::where('pid',$item['id'])->with('goodsName')->field('goods,nums,price sell')->limit(3)->select();
+                $item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with('goodsName')->field('product_id,cart_num')->limit(3)->select();
                 $item['goods_count']=count(explode(',',$item['cart_id']));
             })
             ->toArray();
@@ -64,7 +66,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
      */
     public function count(): int
     {
-        return Cashierclass::where($this->searchWhere)->count();
+        return StoreOrder::where($this->searchWhere)->count();
     }
 
 }
\ No newline at end of file
diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php
index affc9f344..807434814 100644
--- a/app/api/lists/product/ProductLists.php
+++ b/app/api/lists/product/ProductLists.php
@@ -112,26 +112,14 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
 
         }
         $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'])
+        return 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','unit'])
             ->limit($this->limitOffset, $this->limitLength)
-            ->with(['className'])
+            ->with(['className','unitName'])
             ->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)
@@ -191,23 +179,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
         $where[]=['store_id','=',$store_id];
 
         $data  =StoreBranchProduct::where($this->searchWhere)->where($where)
-            ->field(['id', 'product_id'])
+            ->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->with(['className','unitName'])
             ->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);
     }
diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php
index dfca1be35..124eb2233 100644
--- a/app/common/model/store_branch_product/StoreBranchProduct.php
+++ b/app/common/model/store_branch_product/StoreBranchProduct.php
@@ -23,6 +23,11 @@ class StoreBranchProduct extends BaseModel
 
 
 
+    public function unitName()
+    {
+        return $this->hasOne(StoreProductUnit::class,'id','unit')->bind(['unit_name'=>'name','is_bulk']);
+    }
+
 
     public function className()
     {
diff --git a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php
index c1e1d212c..a563736ae 100644
--- a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php
+++ b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php
@@ -3,7 +3,7 @@
 namespace app\common\model\store_order_cart_info;
 
 use app\common\model\BaseModel;
-use app\common\model\store_product\StoreProduct;
+use app\common\model\store_branch_product\StoreBranchProduct;
 use think\model\concern\SoftDelete;
 
 class StoreOrderCartInfo extends BaseModel
@@ -14,6 +14,6 @@ class StoreOrderCartInfo extends BaseModel
 
     public function goodsName()
     {
-        return $this->hasOne(StoreProduct::class,'id','product_id')->bind(['store_name','image','unit','price']);
+        return $this->hasOne(StoreBranchProduct::class,'id','product_id')->bind(['store_name','image','unit','price']);
     }
 }
\ No newline at end of file