Przeglądaj źródła

Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev

evoxwht 2 lat temu
rodzic
commit
63bdd30606

+ 1 - 1
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -360,7 +360,7 @@ class SystemCrud extends AuthController
         if (config('filesystem.password') != $pwd) {
             return app('json')->fail('文件管理密码错误');
         }
-        
+
         if (empty($filepath) || !$id) {
             return app('json')->fail(410087);
         }

+ 8 - 4
crmeb/app/services/system/SystemCrudServices.php

@@ -172,10 +172,10 @@ class SystemCrudServices extends BaseServices
 //                    'value' => 'dateTimeRange',
 //                    'label' => '日期时间区间选择',
 //                ],
-                [
-                    'value' => 'checkbox',
-                    'label' => '多选框',
-                ],
+//                [
+//                    'value' => 'checkbox',
+//                    'label' => '多选框',
+//                ],
                 [
                     'value' => 'radio',
                     'label' => '单选框',
@@ -811,6 +811,10 @@ class SystemCrudServices extends BaseServices
                 if (in_array($fieldType, ['text', 'longtext', 'tinytext'])) {
                     unset($option['limit']);
                 }
+                //判断字段类型
+                if ($fieldType == 'boolean' && isset($option['default']) && $option['default'] === '') {
+                    unset($option['default']);
+                }
                 $table->addColumn($item['field'], $this->changeTabelRule($item['field_type']), $option);
             }
         }

+ 2 - 3
crmeb/crmeb/services/AccessTokenServeService.php

@@ -146,15 +146,14 @@ class AccessTokenServeService extends HttpService
      * @param bool $isHeader
      * @return array|mixed
      */
-    public function httpRequest(string $url, array $data = [], string $method = 'POST', bool $isHeader = true)
+    public function httpRequest(string $url, array $data = [], string $method = 'POST', bool $isHeader = true, array $header = [])
     {
-        $header = [];
         if ($isHeader) {
             $this->getToken();
             if (!$this->accessToken) {
                 throw new ApiException(410086);
             }
-            $header = ['Authorization:Bearer-' . $this->accessToken];
+            $header = array_merge($header, ['Authorization:Bearer-' . $this->accessToken]);
         }
 
         $res = $this->request($this->get($url), $method, $data, $header);

+ 6 - 0
crmeb/crmeb/services/crud/Make.php

@@ -81,6 +81,12 @@ abstract class Make
      */
     protected $value = [];
 
+    /**
+     * 数据库获取器后缀
+     * @var string
+     */
+    protected $attrPrefix = '_label';
+
     /**
      * 后台前端模板根路径
      * @var string

+ 75 - 2
crmeb/crmeb/services/crud/Model.php

@@ -14,6 +14,8 @@
 namespace crmeb\services\crud;
 
 
+use think\helper\Str;
+
 /**
  * Class Model
  * @author 等风来
@@ -57,9 +59,73 @@ class Model extends Make
             $this->value['content-php'] = $this->tab() . "use SoftDelete;\n";
         }
         $this->value['modelName'] = $options['modelName'] ?? $name;
+        $field = $options['fromField'] ?? [];
+
+        $attrFnContent = [];
+        foreach ($field as $item) {
+            if (in_array($item['type'], ['radio', 'select']) && !empty($item['option'])) {
+                $attrFnContent[] = $this->getAttrFnContent($item['field'], $item['name'], $item['option']);
+            }
+        }
+        if ($attrFnContent) {
+            $this->value['attr-php'] = "\n" . implode("\n", $attrFnContent);
+        }
+
         return parent::handle($name, $options);
     }
 
+    /**
+     *
+     * @param string $key
+     * @param array $options
+     * @return array|false|string|string[]
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/5/11
+     */
+    protected function getAttrFnContent(string $key, string $comment, array $options)
+    {
+        $attrFnStub = file_get_contents($this->getStub('attr'));
+        $var = ['{%field%}', '{%date%}', '{%name%}', '{%content-php%}'];
+        $value = [
+            Str::studly($key . $this->attrPrefix),
+            date('Y-m-d'),
+            $comment,
+            $this->getSwithAndSelectPhpContent($options)
+        ];
+
+        return str_replace($var, $value, $attrFnStub);
+    }
+
+    /**
+     * 获取开关和下拉框获取器内容
+     * @param array $options
+     * @return string
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/5/11
+     */
+    protected function getSwithAndSelectPhpContent(array $options)
+    {
+        if (!$options) {
+            return '';
+        }
+        $case = [];
+        foreach ($options as $option) {
+            $case[] = $this->tab(3) . "case " . $option['value'] . ":\n" . $this->tab(4) . "\$attr = '$option[label]';\n" . $this->tab(4) . "break;";
+        }
+        $caseContent = implode("\n", $case);
+        $tab2 = $this->tab(2);
+        $content = <<<CONTENT
+{$tab2}\$attr = '';
+{$tab2}switch ((int)\$value){
+{$caseContent}
+{$tab2}}
+{$tab2}return \$attr;
+CONTENT;
+        return $content;
+    }
+
     /**
      * @param string $path
      * @param string $name
@@ -83,8 +149,15 @@ class Model extends Make
      * @email 136327134@qq.com
      * @date 2023/3/13
      */
-    protected function getStub(string $type = '')
+    protected function getStub(string $type = 'model')
     {
-        return __DIR__ . DS . 'stubs' . DS . 'model' . DS . 'crudModel.stub';
+        $routePath = __DIR__ . DS . 'stubs' . DS . 'model' . DS;
+
+        $stubs = [
+            'model' => $routePath . 'crudModel.stub',
+            'attr' => $routePath . 'getattr.stub',
+        ];
+
+        return $type ? $stubs[$type] : $stubs['model'];
     }
 }

+ 15 - 4
crmeb/crmeb/services/crud/Service.php

@@ -59,12 +59,20 @@ class Service extends Make
             $contentAction .= $stub . "\n";
         }
 
-        //生成form表单
-        if (in_array('save', $action) || in_array('update', $action)) {
-            $var = ['{%key%}', '{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}'];
+        if ($field) {
+            //生成form表单
+            $var = ['{%key%}', '{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}', '{%field%}'];
             $value = [$options['key'] ?? 'id', $this->value['date'], Str::snake($options['route'] ?? $name)];
             $from = [];
+            $select = [];
             foreach ($field as $item) {
+                //处理查询字段
+                if (in_array($item['type'], ['radio', 'select', 'checkbox'])) {
+                    $select[] = $item['field'] . ' as ' . $item['field'] . $this->attrPrefix;
+                } else {
+                    $select[] = $item['field'];
+                }
+                //处理表单信息
                 switch ($item['type']) {
                     case 'frameImageOne':
                         $from[] = $this->tab(2) . $this->getframeImageOnePhpContent($item['field'], $item['name']) . ';';
@@ -95,7 +103,10 @@ class Service extends Make
                 $value[] = '';
             }
             $value[] = $options['modelName'] ?? $options['menus'] ?? $name;
-
+            if (!empty($options['key'])) {
+                array_push($select, $options['key']);
+            }
+            $value[] = implode(',', $select);
             if ($value && $var) {
                 $contentAction = str_replace($var, $value, $contentAction);
             }

+ 5 - 2
crmeb/crmeb/services/crud/ViewPages.php

@@ -75,6 +75,7 @@ class ViewPages extends Make
         $contentVue = [];
         foreach ($field as $key => $item) {
             $keyName = 'key';
+            $fieldValue = $item['field'];
             if (isset($item['type'])) {
                 switch ($item['type']) {
                     case 'frameImageOne':
@@ -88,9 +89,11 @@ class ViewPages extends Make
                         $contentVue[] = str_replace(['{%field%}'], [$item['field']], $templateContent);
                         break;
                 }
+                if (in_array($item['type'], ['radio', 'select', 'checkbox'])) {
+                    $fieldValue = $fieldValue . $this->attrPrefix;
+                }
             }
-
-            $columnStr[] = ($key == 0 ? $this->tab(2) : '') . "{\n" . $this->tab(3) . "title:\"{$item['name']}\"," . $this->tab(2) . "\n" . $this->tab(3) . "$keyName:\"{$item['field']}\"\n" . $this->tab(2) . "}\n";
+            $columnStr[] = ($key == 0 ? $this->tab(2) : '') . "{\n" . $this->tab(3) . "title:\"{$item['name']}\"," . $this->tab(2) . "\n" . $this->tab(3) . "$keyName:\"{$fieldValue}\"\n" . $this->tab(2) . "}\n";
         }
         $this->value['auth'] = Str::snake($name);
         $this->value['componentName'] = $this->value['auth'];

+ 1 - 1
crmeb/crmeb/services/crud/stubs/controller/delete.stub

@@ -10,7 +10,7 @@
             return app('json')->fail(100100);
         }
 
-        if ($this->service->destroy($id)) {
+        if ($this->service->destroy((int)$id)) {
             return app('json')->success(100002);
         } else {
             return app('json')->success(100008);

+ 1 - 1
crmeb/crmeb/services/crud/stubs/controller/edit.stub

@@ -6,5 +6,5 @@
      */
     public function edit($id)
     {
-        return app('json')->success($this->service->getCrudForm($id));
+        return app('json')->success($this->service->getCrudForm((int)$id));
     }

+ 1 - 1
crmeb/crmeb/services/crud/stubs/model/crudModel.stub

@@ -41,5 +41,5 @@ class {%nameCamel%} extends BaseModel
      * @var string
      */
     protected $pk = '{%key%}';
-
+{%attr-php%}
 }

+ 6 - 0
crmeb/crmeb/services/crud/stubs/model/getattr.stub

@@ -1,3 +1,9 @@
+    /**
+     * {%name%}获取器
+     * @date {%date%}
+     * @param string $value
+     * @return string
+     */
     public function get{%field%}Attr($value)
     {
 {%content-php%}

+ 1 - 1
crmeb/crmeb/services/crud/stubs/service/crudListIndex.stub

@@ -7,7 +7,7 @@
     public function getCrudListIndex(array $where = [])
     {
         [$page, $limit] = $this->getPageValue();
-        $model = $this->dao->selectModel($where, '*', 0, 0, '{%key%} desc');
+        $model = $this->dao->selectModel($where, '{%field%}', 0, 0, '{%key%} desc');
 
         return ['count' => $model->count(), 'list' => $model->page($page ?: 1, $limit ?: 10)->select()->toArray()];
     }

+ 1 - 1
crmeb/crmeb/services/express/storage/Express.php

@@ -168,7 +168,7 @@ class Express extends BaseExpress
         if (!$data['siid']) {
             $param['print_type'] = 'IMAGE';
         }
-        return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST');
+        return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST', true, ['version:v1.1']);
     }
 
 }

+ 3 - 0
crmeb/public/install/crmeb.sql

@@ -28453,6 +28453,9 @@ CREATE TABLE IF NOT EXISTS `eb_store_order` (
   `delivery_code` varchar(50) NOT NULL DEFAULT '' COMMENT '快递公司编码',
   `delivery_type` varchar(32) NOT NULL DEFAULT '' COMMENT '发货类型',
   `delivery_id` varchar(64) NOT NULL DEFAULT '' COMMENT '快递单号/手机号',
+  `kuaidi_label` varchar(255) NOT NULL DEFAULT '' COMMENT '快递单号图片',
+  `kuaidi_task_id` varchar(64) NOT NULL DEFAULT '' COMMENT '快递单任务id',
+  `kuaidi_order_id` varchar(64) NOT NULL DEFAULT '' COMMENT '快递单订单号',
   `fictitious_content` varchar(500) NOT NULL DEFAULT '' COMMENT '虚拟发货内容',
   `delivery_uid` int(11) NOT NULL DEFAULT '0' COMMENT '配送员id',
   `gain_integral` decimal(8,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '消费赚取积分',

+ 5 - 0
template/admin/package-lock.json

@@ -19377,6 +19377,11 @@
         }
       }
     },
+    "print-js": {
+      "version": "1.6.0",
+      "resolved": "https://registry.npmmirror.com/print-js/-/print-js-1.6.0.tgz",
+      "integrity": "sha512-BfnOIzSKbqGRtO4o0rnj/K3681BSd2QUrsIZy/+WdCIugjIswjmx3lDEZpXB2ruGf9d4b3YNINri81+J0FsBWg=="
+    },
     "printj": {
       "version": "1.1.2",
       "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz",

+ 1 - 0
template/admin/package.json

@@ -43,6 +43,7 @@
     "monaco-editor": "^0.28.1",
     "monaco-editor-webpack-plugin": "^4.2.0",
     "oss": "0.0.1",
+    "print-js": "^1.6.0",
     "qiniu-js": "^2.5.5",
     "qrcodejs2": "0.0.2",
     "qs": "^6.6.0",

+ 2 - 2
template/admin/src/layout/navBars/breadcrumb/user.vue

@@ -194,8 +194,8 @@ export default {
                   done();
                   this.$Message.success('您已成功退出');
                   this.$store.commit('clearAll');
-                  localStorage.clear();
-                  sessionStorage.clear();
+                  // localStorage.clear();
+                  // sessionStorage.clear();
                   removeCookies('token');
                   removeCookies('expires_time');
                   removeCookies('uuid');

+ 16 - 0
template/admin/src/pages/order/orderList/components/tableList.vue

@@ -147,6 +147,7 @@
               <!--                            <DropdownItem name="7"  v-show='row._status === 3'>不退款</DropdownItem>-->
               <DropdownItem name="8" v-show="row._status === 4">已收货</DropdownItem>
               <DropdownItem name="9">删除订单</DropdownItem>
+              <DropdownItem name="12" v-show="row.kuaidi_label">快递面单打印</DropdownItem>
             </DropdownMenu>
           </Dropdown>
         </template>
@@ -190,6 +191,7 @@
 
 <script>
 import expandRow from './tableExpand.vue';
+import printJS from 'print-js';
 import {
   orderList,
   getOrdeDatas,
@@ -417,6 +419,9 @@ export default {
               this.$Message.error(res.msg);
             });
           break;
+        case '12':
+          this.printImg(row.kuaidi_label);
+          break;
         default:
           this.delfromData = {
             title: '删除订单',
@@ -428,6 +433,17 @@ export default {
           this.delOrder(row, this.delfromData);
       }
     },
+    printImg(url) {
+      printJS({
+        printable: url,
+        type: 'image',
+        documentTitle: '快递信息',
+        style: `img{
+          width: 100%;
+          height: 476px;
+        }`,
+      });
+    },
     // 立即支付 /确认收货//删除单条订单
     submitModel() {
       this.getList();

+ 15 - 1
template/admin/src/pages/order/orderList/handle/orderSend.vue

@@ -154,6 +154,7 @@ import {
   orderSheetInfo,
   splitCartInfo,
 } from '@/api/order';
+import printJS from 'print-js';
 export default {
   name: 'orderSend',
   props: {
@@ -352,6 +353,18 @@ export default {
           this.$Message.error(res.msg);
         });
     },
+    printImg(url) {
+      printJS({
+        printable: url,
+        type: 'image',
+        documentTitle: '快递信息',
+        style: `img{
+          width: 100%;
+          height: 476px;
+        }`,
+      });
+    },
+
     // 提交
     putSend(name) {
       let data = {
@@ -385,7 +398,6 @@ export default {
           return this.$Message.error('送货人不能为空');
         }
       }
-
       if (this.splitSwitch) {
         data.datas.cart_ids = [];
         this.selectData.forEach((v) => {
@@ -401,6 +413,7 @@ export default {
             this.$emit('submitFail');
             this.reset();
             this.splitSwitch = false;
+            if (res.data.label) this.printImg(res.data.label);
           })
           .catch((res) => {
             this.$Message.error(res.msg);
@@ -413,6 +426,7 @@ export default {
             this.splitSwitch = false;
             this.$emit('submitFail');
             this.reset();
+            if (res.data.label) this.printImg(res.data.label);
           })
           .catch((res) => {
             this.$Message.error(res.msg);

+ 3 - 11
template/admin/src/pages/statistic/product/components/productInfo.vue

@@ -16,21 +16,13 @@
             <div>在选定条件下,添加商品进入购物车的商品件数</div>
             <br />
             <div>下单件数</div>
-            <div>
-              在选定条件下,成功下单的商品件数之和(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入,不剔除退款订单)
-            </div>
+            <div>在选定条件下,成功下单的商品件数之和(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入,不剔除退款订单)</div>
             <br />
             <div>支付件数</div>
-            <div>
-              在选定条件下,
-              成功付款订单的商品件数之和(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入,不剔除退款订单)
-            </div>
+            <div>在选定条件下,成功付款订单的商品件数之和(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入,不剔除退款订单)</div>
             <br />
             <div>支付金额</div>
-            <div>
-              在选定条件下,
-              成功付款订单的商品金额之和(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入,不剔除退款订单)
-            </div>
+            <div>在选定条件下,成功付款订单的商品金额之和(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入,不剔除退款订单)</div>
             <br />
             <div>成本金额</div>
             <div>在选定条件下,成功付款订单的商品成本金额之和</div>

+ 1 - 4
template/admin/src/pages/statistic/transaction/components/transaction.vue

@@ -13,10 +13,7 @@
             <div>交易毛利金额 = 营业额 - 支出金额</div>
             <br />
             <div>商品支付金额</div>
-            <div>
-              选定条件下,用户购买商品的实际支付金额,包括微信支付、余额支付、支付宝支付、线下支付金额
-              (拼团商品在成团之后计入,线下支付订单在后台确认支付后计入)
-            </div>
+            <div>选定条件下,用户购买商品的实际支付金额,包括微信支付、余额支付、支付宝支付、线下支付金额(拼团商品在成团之后计入,线下支付订单在后台确认支付后计入)</div>
             <br />
             <div>购买会员金额</div>
             <div>选定条件下,用户成功购买付费会员的金额</div>

+ 3 - 4
template/uni-app/pages/goods/order_confirm/index.vue

@@ -616,8 +616,8 @@
 			 * 获取门店列表数据
 			 */
 			getList: function() {
-				let longitude = uni.getStorageSync("user_longitude"); //经度
-				let latitude = uni.getStorageSync("user_latitude"); //纬度
+				let longitude = uni.getStorageSync("user_longitude") || ''; //经度
+				let latitude = uni.getStorageSync("user_latitude") || ''; //纬度
 				let data = {
 					latitude: latitude, //纬度
 					longitude: longitude, //经度
@@ -692,12 +692,11 @@
 							success: (res) => {
 								uni.setStorageSync('user_latitude', res.latitude);
 								uni.setStorageSync('user_longitude', res.longitude);
-								this.getList()
 							},
 							complete: () => {
 								this.getList()
 							}
-						});
+						})
 						// #ifdef H5	
 					}
 					// #endif