joway пре 2 година
родитељ
комит
d169f7e96a

+ 6 - 2
backendApi/config/menu.php

@@ -338,7 +338,11 @@ return [
 //            ['name'=>'提现管理-提现已付款', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-6', 'routePath'=>'finance/withdraw-6', 'show'=>0,],
 //            ['name'=>'提现管理-付款失败', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-4', 'routePath'=>'finance/withdraw-4', 'show'=>0,],
 //            ['name'=>'提现管理-提现退回', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-7', 'routePath'=>'finance/withdraw-7', 'show'=>0,],
-            ['name'=>'Review withdrawal info', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-status', 'routePath'=>'finance/withdraw-status', 'show'=>0], // 审核提现信息
+            ['name'=>'Review withdrawal info', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-status', 'routePath'=>'finance/withdraw-status', 'show'=>0,], // 审核提现信息
+            ['name'=>'提现审核', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-status-audit', 'routePath'=>'finance/withdraw-status-audit', 'show'=>0,],
+            ['name'=>'提现退回', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-status-return', 'routePath'=>'finance/withdraw-status-return', 'show'=>0,],
+            ['name'=>'提现付款', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-status-pay', 'routePath'=>'finance/withdraw-status-pay', 'show'=>0,],
+            ['name'=>'提现取消', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-status-cancel', 'routePath'=>'finance/withdraw-status-cancel', 'show'=>0,],
             //['name'=>'发票信息添加', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'invoice-audit-add', 'routePath'=>'finance/invoice-audit-add', 'show'=>0,],
             //['name'=>'发票信息编辑', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'invoice-audit-edit', 'routePath'=>'finance/invoice-audit-edit', 'show'=>0,],
             //['name'=>'标记付款失败批量1导入', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'import-withdraws-to-excel-table', 'routePath'=>'finance/import-withdraws-to-excel-table', 'show'=>0,],
@@ -519,4 +523,4 @@ return [
             ['name'=>'编辑报单中心级别', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'dec-role-edit', 'routePath'=>'config/dec-role-edit', 'show'=>0,],
         ],
     ],
-];
+];

+ 84 - 73
backendEle/src/views/finance/withdraw.vue

@@ -4,10 +4,10 @@
       <el-tabs v-model="filterStatus" @tab-click="handleFilterStatusClick">
         <el-tab-pane label="All" name="-1" :lazy="true"></el-tab-pane> <!-- 全部 -->
         <el-tab-pane label="To be reviewed" name="0" :lazy="true"></el-tab-pane> <!-- 待审核 -->
-        <el-tab-pane label="Reviewed" name="2" :lazy="true"></el-tab-pane> <!-- 已审核 -->
+<!--        <el-tab-pane label="Reviewed" name="2" :lazy="true"></el-tab-pane> &lt;!&ndash; 已审核 &ndash;&gt;-->
         <el-tab-pane label="To be paid" name="3" :lazy="true"></el-tab-pane> <!-- 待付款 -->
         <el-tab-pane label="Paid" name="6" :lazy="true"></el-tab-pane> <!-- 已付款 -->
-        <el-tab-pane label="Payment failed" name="4" :lazy="true"></el-tab-pane> <!-- 付款失败 -->
+<!--        <el-tab-pane label="Payment failed" name="4" :lazy="true"></el-tab-pane> &lt;!&ndash; 付款失败 &ndash;&gt;-->
         <el-tab-pane label="Returned" name="7" :lazy="true"></el-tab-pane> <!-- 已退回 -->
       </el-tabs>
       <div class="filter-box">
@@ -33,7 +33,7 @@
         <el-table-column fixed="right" label="Action" width="180"> <!-- 操作 -->
           <template slot-scope="scope">
             <el-dropdown size="small" trigger="click"
-                         v-if="scope.row.AUDIT_STATUS!=='7' && (permission.hasPermission(`finance/withdraw-status`))">
+                         v-if="scope.row.AUDIT_STATUS!=='6' && scope.row.AUDIT_STATUS!=='7' && (permission.hasPermission(`finance/withdraw-status`))">
               <el-button type="primary" size="small" @click.stop="">
                 Action<i class="el-icon-arrow-down el-icon--right"></i>
               </el-button>
@@ -43,41 +43,46 @@
                 <!--v-show="(scope.row.AUDIT_STATUS==='0'||scope.row.AUDIT_STATUS==='1') && (permission.hasPermission(`finance/invoice-audit-add`)||permission.hasPermission(`finance/invoice-audit-edit`))">-->
                 <!--补录发票信息-->
                 <!--</el-dropdown-item>-->
-                <el-dropdown-item command="status"
-                                  @click.native="handleStatusShow(scope.row, 2, 'Are you sure to approve the current withdrawal?')"
-                                  v-show="scope.row.AUDIT_STATUS==='0' && permission.hasPermission(`finance/withdraw-status`)"> <!-- 确定对当前提现进行审核通过操作? -->
-                  Approve <!-- 审核通过 -->
-                </el-dropdown-item>
-                <el-dropdown-item command="status"
-                                  @click.native="handleStatusShow(scope.row, 3, 'Are you sure to set the current withdrawal as payment action?')"
-                                  v-show="scope.row.AUDIT_STATUS === '2' && permission.hasPermission(`finance/withdraw-status`)"> <!-- 确定对当前提现进行设为待付款操作? -->
-                  To be paid<!-- 设为待付款 -->
-                </el-dropdown-item>
+<!--                <el-dropdown-item command="status"-->
+<!--                                  @click.native="handleStatusShow(scope.row, 3, 'Are you sure to approve the current withdrawal?')"-->
+<!--                                  v-show="scope.row.AUDIT_STATUS==='0' && permission.hasPermission(`finance/withdraw-status`)"> &lt;!&ndash; 确定对当前提现进行审核通过操作? &ndash;&gt;-->
+<!--                  Approve &lt;!&ndash; 审核通过 &ndash;&gt;-->
+<!--                </el-dropdown-item>-->
+<!--                <el-dropdown-item command="status"-->
+<!--                                  @click.native="handleStatusShow(scope.row, 3, 'Are you sure to set the current withdrawal as payment action?')"-->
+<!--                                  v-show="scope.row.AUDIT_STATUS === '0' && permission.hasPermission(`finance/withdraw-status`)"> &lt;!&ndash; 确定对当前提现进行设为待付款操作? &ndash;&gt;-->
+<!--                  Approve&lt;!&ndash; 设为待付款 &ndash;&gt;-->
+<!--                </el-dropdown-item>-->
                 <el-dropdown-item command="status"
                                   @click.native="handleStatusShow(scope.row, 6, 'Are you sure to set the current withdrawal as paid?')"
-                                  v-show="scope.row.AUDIT_STATUS === '3' && permission.hasPermission(`finance/withdraw-status`)"> <!-- 确定对当前提现进行设为已付款操作 -->
-                  Paid<!--设为已付款-->
-                </el-dropdown-item>
-                <el-dropdown-item command="status"
-                                  @click.native="handleStatusShow(scope.row, 3, 'Are you sure to set the current withdrawal as payment action??')"
-                                  v-show="scope.row.AUDIT_STATUS === '4' && permission.hasPermission(`finance/withdraw-status`)"> <!-- 确定对当前提现进行设为待付款操作? -->
-                  To be paid<!-- 设为待付款 -->
+                                  v-show="scope.row.AUDIT_STATUS === '3' && permission.hasPermission(`finance/withdraw-status-pay`)"> <!-- 确定对当前提现进行设为已付款操作 -->
+                  Paid<!--付款-->
                 </el-dropdown-item>
                 <el-dropdown-item command="status"
-                                  @click.native="handleStatusShow(scope.row, 4, 'Are you sure to set payment failure for the current withdrawal?', 'Note')"
-                                  v-show="scope.row.AUDIT_STATUS === '6' && permission.hasPermission(`finance/withdraw-status`)"> <!-- 付款失败备注 --> <!-- 确定对当前提现进行设为付款失败操作 -->
-                  Failed<!-- 设为付款失败 -->
+                                  @click.native="handleStatusShow(scope.row, 3, 'Are you sure to set the current withdrawal as approved?')"
+                                  v-show="scope.row.AUDIT_STATUS === '0' && permission.hasPermission(`finance/withdraw-status-audit`)"> <!-- 确定对当前提现进行设为已付款操作 -->
+                  Approve<!--审核通过-->
                 </el-dropdown-item>
+<!--                <el-dropdown-item command="status"-->
+<!--                                  @click.native="handleStatusShow(scope.row, 4, 'Are you sure to set payment failure for the current withdrawal?', 'Note')"-->
+<!--                                  v-show="scope.row.AUDIT_STATUS === '6' && permission.hasPermission(`finance/withdraw-status`)"> &lt;!&ndash; 付款失败备注 &ndash;&gt; &lt;!&ndash; 确定对当前提现进行设为付款失败操作? &ndash;&gt;-->
+<!--                  Failed&lt;!&ndash; 设为付款失败 &ndash;&gt;-->
+<!--                </el-dropdown-item>-->
                 <el-dropdown-item command="status"
                                   @click.native="handleStatusShow(scope.row, 7, 'Determines that the current withdrawal is set to a withdrawal return operation?', 'Note on withdrawal return')"
-                                  v-show="scope.row.AUDIT_STATUS === '0' && permission.hasPermission(`finance/withdraw-status`)"> <!-- 确定对当前提现进行设为提现退回操作? --> <!-- 提现退回备注 -->
-                  Return <!-- 设为提现退回 -->
+                                  v-show="(scope.row.AUDIT_STATUS === '0') && permission.hasPermission(`finance/withdraw-status-return`)"><!-- 提现退回备注 -->
+                  Return <!-- 该会员已提供发票,请确认是否处理提现退回 --> <!-- 设为提现退回 -->
                 </el-dropdown-item>
                 <el-dropdown-item command="status"
                                   @click.native="handleStatusShow(scope.row, 7, 'The member has provided the invoice, please confirm whether to process the withdrawal return?', 'Note on withdrawal return')"
-                                  v-show="(scope.row.AUDIT_STATUS === '1'||scope.row.AUDIT_STATUS === '2'||scope.row.AUDIT_STATUS === '3') && permission.hasPermission(`finance/withdraw-status`)"><!-- 提现退回备注 -->
+                                  v-show="(scope.row.AUDIT_STATUS === '1'||scope.row.AUDIT_STATUS === '2') && permission.hasPermission(`finance/withdraw-status-return`)"><!-- 提现退回备注 -->
                   Return <!-- 该会员已提供发票,请确认是否处理提现退回 --> <!-- 设为提现退回 -->
                 </el-dropdown-item>
+                <el-dropdown-item command="status"
+                                  @click.native="handleStatusShow(scope.row, 0, 'Are you sure to set the current withdrawal as canceled?', 'Note on withdrawal return')"
+                                  v-show="scope.row.AUDIT_STATUS === '3' && permission.hasPermission(`finance/withdraw-status-cancel`)"> <!-- 确定对当前提现进行设为提现退回操作? --> <!-- 提现退回备注 -->
+                  Cancel <!-- 取消审核 -->
+                </el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
           </template>
@@ -86,27 +91,27 @@
       <div class="white-box-footer">
 
         <el-dropdown size="small" trigger="click" @command="handleMuli"
-                     v-if="filterStatus!=='-1' && filterStatus!=='7' && (permission.hasPermission(`finance/withdraw-status`))">
+                     v-if="filterStatus!=='-1' && filterStatus!=='6' && filterStatus!=='7' && (permission.hasPermission(`finance/withdraw-status`))">
           <el-button type="primary" size="small">
             Selected data<!--所选数据--><i class="el-icon-arrow-down el-icon--right"></i>
           </el-button>
           <el-dropdown-menu v-if="filterStatus==='0'" slot="dropdown">
-            <el-dropdown-item command="2">Batch audit passed</el-dropdown-item> <!-- 批量审核通过-->
-            <el-dropdown-item command="7">Batch return</el-dropdown-item> <!-- 批量退回 -->
-          </el-dropdown-menu>
-          <el-dropdown-menu v-else-if="filterStatus==='2'" slot="dropdown">
-            <el-dropdown-item command="3">Batch set to be paid</el-dropdown-item><!-- 批量设为待付款 -->
+            <el-dropdown-item command="3" v-show="permission.hasPermission(`finance/withdraw-status-audit`)">Batch audit passed</el-dropdown-item> <!-- 批量审核通过-->
+            <el-dropdown-item command="7" v-show="permission.hasPermission(`finance/withdraw-status-return`)">Batch return</el-dropdown-item> <!-- 批量退回 -->
           </el-dropdown-menu>
+<!--          <el-dropdown-menu v-else-if="filterStatus==='2'" slot="dropdown">-->
+<!--            <el-dropdown-item command="3">Batch set to be paid</el-dropdown-item>&lt;!&ndash; 批量设为待付款 &ndash;&gt;-->
+<!--          </el-dropdown-menu>-->
           <el-dropdown-menu v-else-if="filterStatus==='3'" slot="dropdown">
-            <el-dropdown-item command="6">Batch set paid</el-dropdown-item><!--批量设为已付款-->
-            <el-dropdown-item command="7">Batch return</el-dropdown-item><!--批量退回-->
-          </el-dropdown-menu>
-          <el-dropdown-menu v-else-if="filterStatus==='6'" slot="dropdown">
-            <el-dropdown-item command="4">Batch set payment failure</el-dropdown-item><!--批量设为付款失败-->
-          </el-dropdown-menu>
-          <el-dropdown-menu v-else-if="filterStatus==='4'" slot="dropdown">
-            <el-dropdown-item command="3">Batch set to be paid</el-dropdown-item><!-- 批量设为待付款 -->
+            <el-dropdown-item command="6" v-show="permission.hasPermission(`finance/withdraw-status-pay`)">Batch set paid</el-dropdown-item><!--批量设为已付款-->
+            <el-dropdown-item command="0" v-show="permission.hasPermission(`finance/withdraw-status-cancel`)">Batch return</el-dropdown-item><!--批量退回-->
           </el-dropdown-menu>
+<!--          <el-dropdown-menu v-else-if="filterStatus==='6'" slot="dropdown">-->
+<!--            <el-dropdown-item command="4">Batch set payment failure</el-dropdown-item>&lt;!&ndash;批量设为付款失败&ndash;&gt;-->
+<!--          </el-dropdown-menu>-->
+<!--          <el-dropdown-menu v-else-if="filterStatus==='4'" slot="dropdown">-->
+<!--            <el-dropdown-item command="3">Batch set to be paid</el-dropdown-item>&lt;!&ndash; 批量设为待付款 &ndash;&gt;-->
+<!--          </el-dropdown-menu>-->
         </el-dropdown>
 
         <el-button type="success" size="small" @click="handleExport"
@@ -127,7 +132,7 @@
             </el-form-item>
             <el-form-item label="注册类型">
               <el-select v-model="form.baseInfo.REG_TYPE" placeholder="请选择注册类型" :disabled="true">
-                <el-option v-for="(item,key) in regTypes" :label="item.TYPE_NAME" :value="item.ID"
+                <el-option v-for="(item, key) in regTypes" :label="item.TYPE_NAME" :value="item.ID"
                            :key="item.ID"></el-option>
               </el-select>
             </el-form-item>
@@ -159,7 +164,7 @@
                   type="warning" :closable="false">
           </el-alert>
           <el-form :model="auditForm" label-width="180px" style="width:500px;" v-loading="dialogAuditLoading">
-            <el-form-item label="Estimated date of payment" v-show="filterStatus==='2' || filterStatus==='4'"> <!-- 预计付款日期 -->
+            <el-form-item label="Estimated date of payment" v-show="planPayDateVisible"> <!-- 预计付款日期 -->
               <el-date-picker
                       v-model="auditForm.planPaidAt"
                       type="date"
@@ -219,7 +224,7 @@ export default {
       totalPages: 1,
       totalCount: 1,
       pageSize: 20,
-      pageSizes:  [1, 2, 5, 10, 20, 50, 100],
+      pageSizes: [1, 2, 5, 10, 20, 50, 100],
       tool: tool,
       permission: permission,
       regTypes: baseInfo.regTypes(),
@@ -229,6 +234,7 @@ export default {
       dialogAuditLoading: false,
       dialogAddInvoiceVisible: false,
       dialogAddInvoiceLoading: false,
+      planPayDateVisible: false,
       auditId: null,
       form: {
         id: null,
@@ -236,7 +242,7 @@ export default {
         amount: null,
         planPaidAt: null,
         paidAt: new Date(),
-        createRemark: null,
+        createRemark: null
       },
       invoiceForm: {
         id: null,
@@ -257,16 +263,16 @@ export default {
         sellerBank: null,
         itemName: null,
         invoiceRemark: null,
-        createRemark: null,
+        createRemark: null
       },
       pickerOptions0: {
-        disabledDate(time) {
-          return time.getTime() < Date.now();
+        disabledDate (time) {
+          return time.getTime() < Date.now()
         }
       },
       pickerOptions1: {
-        disabledDate(time) {
-          return time.getTime() < Date.now() - 8.64e7;
+        disabledDate (time) {
+          return time.getTime() < Date.now() - 8.64e7
         }
       },
       auditRemark: '',
@@ -276,19 +282,19 @@ export default {
         selectedIds: [],
         planPaidAt: null,
         createRemark: null,
-        withdrawAudit: '',
+        withdrawAudit: ''
       },
       auditTips: '',
       filterTypes: {},
       filterModel: {},
       excelForm: {
-        rowCount: '',
+        rowCount: ''
       },
-      filterStatus: '0',
+      filterStatus: '0'
     }
   },
   mounted () {
-    this.getData();
+    this.getData()
     // if (permission.hasPermission(`finance/withdraw-7`)) {
     //   this.activeName = 'seven'
     // }
@@ -322,7 +328,7 @@ export default {
           message: 'Select the record to operate on', // 请选择要操作的记录
           type: 'warning'
         })
-        return;
+        return
       }
       this.handleAudit(null, command)
     },
@@ -330,16 +336,16 @@ export default {
       let title = ''
       if (status === '2') {
         title = 'Be sure to pass the review?Note:'// 确定要通过审核?备注:
-      }else if(status === '3') {
+      } else if (status === '3') {
         title = 'Be sure to unpaid the review?Note:'// 确定要设为待付款?备注:
-      }else if(status === '4') {
+      } else if (status === '4') {
         title = 'Be sure to payment failure the review?Note:'// 确定要设为付款失败?备注:
-      }else if(status === '6') {
+      } else if (status === '6') {
         title = 'Be sure to paid the review?Note:'// 确定要设为已付款?备注:
-      }else if(status === '7') {
-        title = 'Be sure to return the review?Note:'//确定要设为已退回?备注:
+      } else if (status === '7') {
+        title = 'Be sure to return the review?Note:'// 确定要设为已退回?备注:
       }
-      this.handleStatusShow(row,status,title);
+      this.handleStatusShow(row, status, title)
     },
     handleExpand (row, event, column) {
       this.$refs.multipleTable.toggleRowExpansion(row)
@@ -389,7 +395,7 @@ export default {
     handleEdit () {
       this.dialogEditFormVisible = false
       this.$message({
-        message: 'Modifying data',//正在修改数据
+        message: 'Modifying data', // 正在修改数据
         type: 'info'
       })
       this.loading = true
@@ -403,14 +409,14 @@ export default {
       }).catch(response => {
       })
     },
-    handleStatusShow(row, status, title, remark = 'Remark') { // 备注
+    handleStatusShow (row, status, title, remark = 'Remark') { // 备注
       this.auditForm = {
         auditTips: '',
         auditStatus: null,
         selectedIds: [],
         planPaidAt: null,
         paidAt: new Date(),
-        remark: null,
+        remark: null
       }
       if (row === null) {
         for (let val of this.multipleSelection) {
@@ -421,7 +427,7 @@ export default {
       }
       if (this.auditForm.selectedIds.length === 0) {
         this.$message({
-          message: 'Select the record to operate on',// 请选择数据
+          message: 'Select the record to operate on', // 请选择数据
           type: 'warning'
         })
         return
@@ -430,6 +436,11 @@ export default {
       this.dialogAuditFormVisible = true
       this.auditForm.auditTips = title
       this.auditForm.auditStatus = status
+      if (status == '3') {
+        this.planPayDateVisible = true
+      } else {
+        this.planPayDateVisible = false
+      }
     },
     handleStatus () {
       network.postData('finance/mult-point', {opType: 2}).then(response => {
@@ -477,26 +488,26 @@ export default {
       }).catch(response => {
       })
     },
-    handleSelectionChange(val) {
+    handleSelectionChange (val) {
       this.multipleSelection = val
     },
-    handleCurrentChange(page) {
+    handleCurrentChange (page) {
       this.getData(page, this.pageSize)
     },
-    handleSizeChange(pageSize) {
+    handleSizeChange (pageSize) {
       this.getData(this.currentPage, pageSize)
     },
-    handleFilterStatusClick(tab, event) {
+    handleFilterStatusClick (tab, event) {
       filterHelper.clearFilterOption(this)
       this.getData()
     },
-    handleFilterUser(filterData) {
+    handleFilterUser (filterData) {
       filterHelper.handleFilterUser(this, filterData)
     },
-    handleFilter() {
+    handleFilter () {
       this.getData()
     },
-    getData(page, pageSize) {
+    getData (page, pageSize) {
       let filterData = this.filterModel
       filterData.filterStatus = this.filterStatus != '-1' ? `=,${this.filterStatus}` : ''
       let vueObj = this
@@ -505,9 +516,9 @@ export default {
         vueObj.filterTypes = response.filterTypes
       })
     },
-    onMessageCallback() {
+    onMessageCallback () {
       this.getData(this.currentPage, this.pageSize)
-    },
+    }
   }
 }
 </script>

+ 3 - 3
backendEle/src/views/shop/goods-add.vue

@@ -48,13 +48,13 @@
                     <template slot="append">%</template>
                   </el-input>
                 </el-form-item>
-                <el-form-item label="US Price($)" p>
+                <el-form-item label="Member Price($)" p>
                     <el-input v-model="form.sellPriceStandard"></el-input>
                 </el-form-item>
-                <el-form-item label="Sales Price(₦)">
+                <el-form-item label="Member Price(₦)">
                     <el-input v-model="form.sellPrice"></el-input>
                 </el-form-item>
-                <el-form-item label="Market Price(₦)">
+                <el-form-item label="Retail Price(₦)">
                   <el-input v-model="form.marketPrice"></el-input>
                 </el-form-item>
                 <el-form-item label="Price BV" v-show="pvDisabled"><!-- 价格BV -->

+ 3 - 3
backendEle/src/views/shop/index.vue

@@ -109,13 +109,13 @@
               <template slot="append">%</template>
             </el-input>
           </el-form-item>
-          <el-form-item label="US Price($)" p>
+          <el-form-item label="Member Price($)" p>
             <el-input v-model="form.sellPriceStandard"></el-input>
           </el-form-item>
-          <el-form-item label="Sales Price(₦)" p>
+          <el-form-item label="Member Price(₦)" p>
             <el-input v-model="form.sellPrice"></el-input>
           </el-form-item>
-          <el-form-item label="Market Price(₦)">
+          <el-form-item label="Retail Price(₦)">
             <el-input v-model="form.marketPrice"></el-input>
           </el-form-item>
           <el-form-item label="Price BV" v-show="pvDisabled"> <!-- 价格BV -->

+ 6 - 3
common/messages/en-US/app.php

@@ -28,6 +28,9 @@ return [
     'insufficientInventory' => 'Insufficient inventory',
     'soldOut' => 'Sold out',
     'productsDoesNotExists' => 'Products does not exists!',
+    'allowOnlyOne' => 'Only 1 can be purchased at a time',
+    'canNotBuy' => 'Please pay in EPP order',
+    'productsDoesSoldOut' => 'Products has sold out!',
     'cashDoesNotAdequate' => '余额不足,无法购买商品',
     'exchangePointDoesNotAdequate' => '兑换积分不足,无法购买商品',
     'travelPointDoesNotAdequate' => '旅游积分不足,无法购买商品',
@@ -199,8 +202,8 @@ return [
     'reportFormatIncorrect' => 'The format of the report data is incorrect',
     'memberNumberCanNotContainChineseCharacters' => 'Member number cannot contain Chinese characters',
     'pleaseSelectTheEntryLevel' => 'Please select the entry level',
-    'totalBVCanNotLessThanSelectedBV' => 'The total BV of self selected goods cannot be less than the BV of the selected entry level',
-    'totalBVCanNotLessThanNextSelectedLevelBV' => 'The total BV of self selected goods cannot exceed the BV value of the next level under the selected level',
+    'totalBVCanNotLessThanSelectedBV' => 'Please choose the correct Entry Level.',
+    'totalBVCanNotLessThanNextSelectedLevelBV' => 'Please choose the correct Entry Level.',
     'incorrectEntryType' => 'Incorrect entry type',
     'MembershipNumberFilledInitialPurchase' => 'Membership number must be filled in for initial purchase',
     'fillTheInstructorNumberTheMember' => 'For the first purchase, you must fill in the instructor number of the member',
@@ -303,4 +306,4 @@ return [
     'dataDoesNotExists' => 'The data does not exist',
 
 
-];
+];

+ 3 - 0
common/messages/zh-CN/app.php

@@ -28,6 +28,9 @@ return [
     'insufficientInventory' => '库存不足',
     'soldOut' => '已下架',
     'productsDoesNotExists' => '商品不存在',
+    'allowOnlyOne' => '分期商品每次只可购买1个',
+    'canNotBuy' => '分期商品请按顺序购买',
+    'productsDoesSoldOut' => '商品已下架',
     'cashDoesNotAdequate' => '余额不足,无法购买商品',
     'exchangePointDoesNotAdequate' => '兑换积分不足,无法购买商品',
     'travelPointDoesNotAdequate' => '旅游积分不足,无法购买商品',

+ 7 - 7
common/models/DeclarationLevel.php

@@ -117,10 +117,10 @@ class DeclarationLevel extends \common\components\ActiveRecord
     // 获取下一级业绩数据
     public static function getNextDecPref($perf) {
         $data = static::find()
-        ->where('PERF>:PERF', 
+        ->where('PERF>:PERF',
             [
-                'PERF'=>$perf, 
-                
+                'PERF'=>$perf,
+
             ]
         )
         ->orderBy('PERF ASC')
@@ -133,10 +133,10 @@ class DeclarationLevel extends \common\components\ActiveRecord
 
     public static function getNextAll($perf){
         $data = static::find()
-        ->where('PERF>:PERF', 
+        ->where('PERF>:PERF',
             [
-                'PERF'=>$perf, 
-                
+                'PERF'=>$perf,
+
             ]
         )
         ->indexBy('ID')
@@ -257,4 +257,4 @@ class DeclarationLevel extends \common\components\ActiveRecord
         }
         return $data;
     }
-}
+}

+ 55 - 0
common/models/Instalment.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ORDER}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 用户ID
+ * @property string $ORDER_TYPE 订单类型:BD, FX
+ * @property string $STAGE 分期阶段
+ * @property int $UPDATE_TIME 修改时间
+ */
+class Instalment extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%INSTALMENT}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+        ];
+    }
+
+    /**
+     * @param $userId
+     * @return integer
+     */
+    public static function getStage($userId) {
+        $user = static::findOneAsArray("USER_ID = :USER_ID", [':USER_ID' => $userId]);
+        if(!$user){
+            return 0;
+        }
+        return $user['STAGE'];
+    }
+
+    public static function getInfo($userId) {
+        $userInfo = static::findOneAsArray("USER_ID = :USER_ID", [':USER_ID' => $userId]);
+        if(!$userInfo){
+            return [
+            ];
+        }
+        return $userInfo;
+    }
+}

+ 26 - 20
common/models/Withdraw.php

@@ -88,8 +88,8 @@ class Withdraw extends \common\components\ActiveRecord {
      */
     public function rules() {
         return [
-            [['USER_ID', 'P_MONTH', 'CREATED_AT', 'PLAN_PAID_AT'], 'required'],
-            [['WITHDRAW_PERIOD_NUM', 'WITHDRAW_YEAR', 'WITHDRAW_MONTH', 'IS_AUTO_WITHDRAW', 'BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY', 'AUDIT_STATUS', 'CREATED_AT', 'UPDATED_AT', 'AUDITED_AT', 'PLAN_PAID_AT', 'PAID_AT', 'PAID_FAIL_AT', 'BACK_FAIL_AT', 'PAY_TYPE'], 'integer'],
+            [['USER_ID', 'P_MONTH', 'CREATED_AT',], 'required'],
+            [['WITHDRAW_PERIOD_NUM', 'WITHDRAW_YEAR', 'WITHDRAW_MONTH', 'IS_AUTO_WITHDRAW', 'BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY', 'AUDIT_STATUS', 'CREATED_AT', 'UPDATED_AT', 'AUDITED_AT', 'PAID_AT', 'PAID_FAIL_AT', 'BACK_FAIL_AT', 'PAY_TYPE'], 'integer'],
             [['AMOUNT','FEES','REAL_AMOUNT'], 'number'],
             [['ID', 'SN', 'USER_ID', 'INVOICE_ID', 'OPEN_BANK', 'BANK_NO', 'UPDATE_ADMIN', 'AUDIT_ADMIN'], 'string', 'max' => 32],
             [['ID_CARD'], 'string', 'max' => 20],
@@ -341,42 +341,48 @@ class Withdraw extends \common\components\ActiveRecord {
 //        $msg = '提现单' . $sn . '当前状态为【' . $statusName[$nowStatus] . '】,无法设置为【' . $statusName[$toStatus] . '】';
         $msg = 'The current status of the withdrawal ' . $sn . ' is 【' . $statusName[$nowStatus] . '】, cannot be set to【'.  $statusName[$toStatus] . '】';
         switch ($toStatus) {
-            //审核
-            case Withdraw::STATUS_AUDITED:
-                if ($nowStatus == Withdraw::STATUS_APPLIED) {
+            // 取消审核
+            case Withdraw::STATUS_APPLIED; // 0 待审核 取消审核
+                if ($nowStatus == Withdraw::STATUS_WAIT_PAID) {
                     $msg = '';
                 }
                 break;
+            //已审核
+//            case Withdraw::STATUS_AUDITED: // 2 已审核
+//                if ($nowStatus == Withdraw::STATUS_APPLIED) {
+//                    $msg = '';
+//                }
+//                break;
             //待付款
-            case Withdraw::STATUS_WAIT_PAID:
-                if ($nowStatus == Withdraw::STATUS_AUDITED || $nowStatus == Withdraw::STATUS_PAID_FALSE) {
+            case Withdraw::STATUS_WAIT_PAID: // 3 待复核
+                if ($nowStatus == Withdraw::STATUS_APPLIED) {
                     $msg = '';
                 }
                 break;
             //已付款
-            case Withdraw::STATUS_PAID:
+            case Withdraw::STATUS_PAID: // 6 已付款
                 if ($nowStatus == Withdraw::STATUS_WAIT_PAID) {
                     $msg = '';
                 }
                 break;
             //付款失败
-            case Withdraw::STATUS_PAID_FALSE:
-                if ($nowStatus == Withdraw::STATUS_PAID) {
-                    $msg = '';
-                }
-                break;
+//            case Withdraw::STATUS_PAID_FALSE:
+//                if ($nowStatus == Withdraw::STATUS_PAID) {
+//                    $msg = '';
+//                }
+//                break;
             //提现退回
-            case Withdraw::STATUS_RETURN:
-                if ($nowStatus == Withdraw::STATUS_APPLIED  || $nowStatus == Withdraw::STATUS_AUDITED || Withdraw::STATUS_WAIT_PAID) {
-                    $msg = '';
-                }
-                break;
-            //审核拒绝
-            case Withdraw::STATUS_REFUSED:
+            case Withdraw::STATUS_RETURN: // 7 已退回
                 if ($nowStatus == Withdraw::STATUS_APPLIED) {
                     $msg = '';
                 }
                 break;
+            //审核拒绝
+//            case Withdraw::STATUS_REFUSED:
+//                if ($nowStatus == Withdraw::STATUS_APPLIED) {
+//                    $msg = '';
+//                }
+//                break;
             default:
         }
         return $msg;

+ 40 - 5
common/models/forms/ApproachDeclarationForm.php

@@ -28,6 +28,7 @@ use common\models\User;
 use common\models\UserInfo;
 use common\models\UserNetwork;
 use common\models\UserRelation;
+use common\models\Instalment;
 use Yii;
 use yii\base\Exception;
 
@@ -648,6 +649,7 @@ class ApproachDeclarationForm extends Model
                     $totalAmount = 0;
                     $totalAmountStandard = 0;
                     $totalPv = 0;
+                    $hasInstalment = 0;
                     $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                     foreach ($this->goodsNum as $k => $v) {
                         if ($v) {
@@ -674,10 +676,16 @@ class ApproachDeclarationForm extends Model
                                     'TAX_RATE' => $goods['TAX_RATE'],
                                 ];
                             }
+                            if($goods['INSTALMENT']>0){
+                                $hasInstalment = $goods['INSTALMENT'];
+                            }
                         }
                     }
-                    if ($totalPv < $decLevel['PERF']) {
-                        throw new Exception(Yii::t('app', 'totalBVCanNotLessThanSelectedBV'));
+                    if($totalPv<$decLevel['PERF']){
+                        if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+                        }else{
+                            throw new Exception(Yii::t('app', 'totalBVCanNotLessThanSelectedBV'));
+                        }
                     }
                     foreach ($decLevelConfig as $key => $val) {
                         if ($totalPv >= $val['PERF']) {
@@ -685,7 +693,10 @@ class ApproachDeclarationForm extends Model
                         }
                     }
                     if ($this->decLv != $toDecLevel) {
-                        throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
+                        if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+                        }else{
+                            throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
+                        }
                     }
                     $this->_decAmount = $totalAmount;
                     $this->_decPv = $totalPv;
@@ -693,7 +704,7 @@ class ApproachDeclarationForm extends Model
                     $this->_standardAmount = $this->_decAmountStandard;
                 }
 
-                if (!($this->addUser($allData))) {
+                if (!($zcResult = $this->addUser($allData))) {
                     throw new Exception(Form::formatErrorsForApi($this->_userForm->getErrors()));
                 }
 
@@ -701,7 +712,11 @@ class ApproachDeclarationForm extends Model
                 if (!$decResult) {
                     throw new Exception(Form::formatErrorsForApi($decResult->getErrors()));
                 }
-
+                if($hasInstalment){
+                    if(!($instalmentResult = $this->insertInstalment($zcResult))) {
+                        throw new Exception(Form::formatErrorsForApi('h'));
+                    }
+                }
                 return $decResult;
             } catch (\Exception $e) {
 //                throw new Exception(Form::formatErrorsForApi($e->getFile() . ' ' . $e->getLine() . ' ' . $e->getMessage()));
@@ -923,4 +938,24 @@ class ApproachDeclarationForm extends Model
         return true;
     }
 
+    /**
+     * 添加会员分期付款记录
+     * @param $allData
+     * @return bool|UserInfo|null
+     * @throws \yii\db\Exception
+     */
+    public function insertInstalment($zcResult){
+        // 增加会员分期付款记录
+        $instalment = new Instalment();
+        $instalment->USER_ID = $zcResult->USER_ID;
+        $instalment->STAGE = 1;
+        $instalment->ORDER_TYPE = 'BD';
+        $instalment->UPDATE_TIME = time();
+
+        if (!$instalment->save()) {
+            throw new Exception(Form::formatErrorsForApi($instalment->getErrors()));
+        }
+        return $instalment;
+    }
+
 }

+ 10 - 2
common/models/forms/ApproachDeclarationLoopForm.php

@@ -122,7 +122,7 @@ class ApproachDeclarationLoopForm extends Model
                 if (isset($value['packageId']) && $value['packageId']){
                     $packagedata = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $value['packageId']]);
                     if (!$packagedata) {
-                        throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                        throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                     }
                     if($packagedata['STORE_NUMS']>0){
                         $data =  DeclarationPackage::find()->where(['ID'=> $packagedata['ID'] ])->one();
@@ -144,7 +144,15 @@ class ApproachDeclarationLoopForm extends Model
                     for ($i = 0; $i < count($value['goodsId']) ;$i++) {
                         $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $value['goodsId'][$i]]);
                         if (!$goods) {
-                            throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                            throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
+                        }
+                        if($goods['INSTALMENT']>0){ // 分期的商品
+                            if($value['goodsNum'][$i]>1){ // 只能购买一个
+                                throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                            }
+                        }
+                        if($goods['INSTALMENT']>1){ // 不允许购买“非第一期”的商品
+                            throw new Exception(Yii::t('app', 'canNotBuy'));
                         }
                         if ($goods['STATUS'] == 1 ){
                             if($goods['STORE_NUMS'] >= $value['goodsNum'][$i]) {

+ 28 - 1
common/models/forms/ApproachOrderForm.php

@@ -26,6 +26,7 @@ use common\models\Region;
 use common\models\ShopGoods;
 use common\models\User;
 use common\models\UserNetwork;
+use common\models\Instalment;
 use Yii;
 use yii\base\Exception;
 
@@ -410,12 +411,13 @@ class ApproachOrderForm extends Model
         $totalPv = 0;
         $totalAmountStandard = 0;
         $goodsType = ShopGoods::GOODS_TYPE;
+        $hasInstalment = 0;
         $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                 if (!$goods) {
-                    throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                    throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                 }
                 if($goods['STORE_NUMS']>0){
                     if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
@@ -452,6 +454,21 @@ class ApproachOrderForm extends Model
                         'EXCHANGE_RATE' => $exchangeRate,
                     ];
                 }
+                if($goods['INSTALMENT']>0){ // 如果有分期付款商品,检查用户的分期付款状态
+                    if($v>1){ // 不可以购买多个
+                        throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                    }
+                    $loginUserId = \Yii::$app->user->id;
+                    $userStage = Instalment::getStage($loginUserId);
+                    if ($userStage==0 || $userStage == 3){
+
+                    }else{
+                        if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
+                            throw new Exception(Yii::t('app', 'canNotBuy'));
+                        }
+                    }
+                    $hasInstalment = $goods['INSTALMENT'];
+                }
             }
         }
 
@@ -479,6 +496,16 @@ class ApproachOrderForm extends Model
             if (!$orderResult = $this->addOrder()) {
                 throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
             }
+            if ($hasInstalment){ // 如果有分期付款的商品,写入信息至分期付款表
+                $instalmentModel = Instalment::findOne(['USER_ID'=>$loginUserId]);
+                if(!$instalmentModel) {
+                    $instalmentModel = new Instalment();
+                }
+                $instalmentModel->USER_ID = $loginUserId;
+                $instalmentModel->STAGE = $hasInstalment;
+                $instalmentModel->UPDATE_TIME = time();
+                $instalmentModel->save();
+            }
 
             $transaction->commit();
 

+ 1 - 1
common/models/forms/BaApproachDeclarationLoopForm.php

@@ -121,7 +121,7 @@ class BaApproachDeclarationLoopForm extends Model
                 if (isset($value['packageId']) && $value['packageId']){
                     $packagedata = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $value['packageId']]);
                     if (!$packagedata) {
-                        throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                        throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                     }
                     if($packagedata['STORE_NUMS']>0){
                         $data =  DeclarationPackage::find()->where(['ID'=> $packagedata['ID'] ])->one();

+ 1 - 1
common/models/forms/BaApproachOrderForm.php

@@ -355,7 +355,7 @@ class BaApproachOrderForm extends Model
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID = :ID AND STATUS = 1', [':ID' => $ids[$k]]);
                 if (!$goods) {
-                    throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                    throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                 }
                 if ($goods['STORE_NUMS'] > 0) {
                     if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {

+ 1 - 1
common/models/forms/BaDeclarationLoopForm.php

@@ -120,7 +120,7 @@ class BaDeclarationLoopForm extends Model
                     for ($i=0;$i<count($value['goodsId']);$i++){
                         $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $value['goodsId'][$i]]);
                         if (!$goods) {
-                            throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                            throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                         }
                         if ($goods['STATUS'] == 1 ){
                             if($goods['STORE_NUMS'] >= $value['goodsNum'][$i]){

+ 41 - 2
common/models/forms/DeclarationForm.php

@@ -25,6 +25,7 @@ use common\models\User;
 use common\models\UserInfo;
 use common\models\UserNetwork;
 use common\models\UserRelation;
+use common\models\Instalment;
 use Yii;
 use yii\base\Exception;
 
@@ -669,6 +670,7 @@ class DeclarationForm extends Model
                 $totalAmount = 0;
                 $totalAmountStandard = 0;
                 $totalPv = 0;
+                $hasInstalment = 0;
                 $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
@@ -703,17 +705,29 @@ class DeclarationForm extends Model
                             }
                             $data->update();
                         }
+                        if($goods['INSTALMENT']>0){
+                            $hasInstalment = $goods['INSTALMENT'];
+                        }
                     }
                 }
                 if($totalPv<$decLevel['PERF']){
-                    throw new Exception(Yii::t('app', 'totalBVCanNotLessThanSelectedBV'));
+                    if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+                    }else{
+                        throw new Exception(Yii::t('app', 'totalBVCanNotLessThanSelectedBV'));
+                    }
                 }
                 foreach ($decLevelConfig as $key=>$val){
                     if($totalPv>=$val['PERF']){
                         $toDecLevel = $key;
                     }
                 }
-                if($this->decLv!=$toDecLevel){
+                if ($this->decLv != $toDecLevel) {
+                    if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+                    }else{
+                        throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
+                    }
+                }
+                if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'BA'){
                     throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
                 }
                 $this->_decAmount = $totalAmount;
@@ -733,6 +747,11 @@ class DeclarationForm extends Model
             if(!($decResult = $this->addDecOrder())) {
                 throw new Exception(Form::formatErrorsForApi($decResult->getErrors()));
             }
+            if($hasInstalment){
+                if(!($instalmentResult = $this->insertInstalment($zcResult))) {
+                    throw new Exception(Form::formatErrorsForApi('h'));
+                }
+            }
         }
         return true;
     }
@@ -957,4 +976,24 @@ class DeclarationForm extends Model
         return true;
     }
 
+    /**
+     * 添加会员分期付款记录
+     * @param $allData
+     * @return bool|UserInfo|null
+     * @throws \yii\db\Exception
+     */
+    public function insertInstalment($zcResult){
+        // 增加会员分期付款记录
+        $instalment = new Instalment();
+        $instalment->USER_ID = $zcResult->USER_ID;
+        $instalment->STAGE = 1;
+        $instalment->ORDER_TYPE = 'BD';
+        $instalment->UPDATE_TIME = time();
+
+        if (!$instalment->save()) {
+            throw new Exception(Form::formatErrorsForApi($instalment->getErrors()));
+        }
+        return $instalment;
+    }
+
 }

+ 10 - 3
common/models/forms/DeclarationLoopForm.php

@@ -117,7 +117,6 @@ class DeclarationLoopForm extends Model
             $model->scenario = $this->scenario;
             $model->allData = $this->data;
             foreach ($this->data as $value){
-				
 				/**
                  * 2022-04-29
                  * York
@@ -127,7 +126,7 @@ class DeclarationLoopForm extends Model
 
                     $packagedata = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $value['packageId']]);
                     if (!$packagedata) {
-                        throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                        throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                     }
                     //var_dump($packagedata['ID']);
                     if($packagedata['STORE_NUMS']<=0){
@@ -139,7 +138,15 @@ class DeclarationLoopForm extends Model
                     for ($i=0;$i<count($value['goodsId']);$i++){
                         $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $value['goodsId'][$i]]);
                         if (!$goods) {
-                            throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                            throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
+                        }
+                        if($goods['INSTALMENT']>0){ // 分期的商品
+                            if($value['goodsNum'][$i]>1){ // 只能购买一个
+                                throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                            }
+                        }
+                        if($goods['INSTALMENT']>1){ // 不允许购买“非第一期”的商品
+                            throw new Exception(Yii::t('app', 'canNotBuy'));
                         }
                         if ($goods['STATUS'] == 1 ){
                             if($goods['STORE_NUMS'] < $value['goodsNum'][$i]){

+ 39 - 7
common/models/forms/DeclarationUpgradeForm.php

@@ -22,6 +22,7 @@ use common\models\ShopGoods;
 use common\models\User;
 use common\models\UserInfo;
 use common\models\UserNetwork;
+use common\models\Instalment;
 use Yii;
 use yii\base\Exception;
 
@@ -58,7 +59,7 @@ class DeclarationUpgradeForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
-    
+
     const TYPE_ZC = 'ZC';
     private $_userForm = null;
     // 全部的安置网上级
@@ -154,6 +155,7 @@ class DeclarationUpgradeForm extends Model
                 $totalAmount = 0;
                 $totalAmountStandard = 0;
                 $totalPv = 0;
+                $hasInstalment = 0;
                 $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
@@ -183,11 +185,30 @@ class DeclarationUpgradeForm extends Model
                                 'TAX_RATE' => $goods['TAX_RATE'],
                             ];
                         }
+                        if($goods['INSTALMENT']>0){ // 如果有分期付款商品,检查用户的分期付款状态
+                            if($v>1){ // 不可以购买多个
+                                throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                            }
+
+                            $userStage = Instalment::getStage($userId);
+                            $userInstalmentInfo = Instalment::getInfo($userId);
+                            if (!$userInstalmentInfo){ // 如果没有分期付款记录
+                                throw new Exception(Yii::t('app', 'canNotBuy'));
+                            } else if ($userInstalmentInfo['ORDER_TYPE']!='BD' || $userStage == 3) { // 如果分期付款记录中,不是报单,或已是3
+                                throw new Exception(Yii::t('app', 'canNotBuy'));
+                            }
+                            if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
+                                throw new Exception(Yii::t('app', 'canNotBuy'));
+                            }
+                            $hasInstalment = $goods['INSTALMENT'];
+                        }
                     }
                 }
                 // 这里特殊是用户原报单PV之和+用户购买的商品总PV
                 $checkPv = $totalPv + $diffPerf;
-                if($checkPv < $decLevel['PERF']) {
+                if ($hasInstalment){ // 如果买了分期付款商品,则不判断总pv
+                    $allData['hasInstalment'] = 1;
+                }else if($checkPv < $decLevel['PERF']) {
                     throw new Exception(Yii::t('app', 'totalPVLessThan'), 400);
                 }
                 foreach ($decLevelConfig as $key=>$val){
@@ -214,6 +235,17 @@ class DeclarationUpgradeForm extends Model
             if(!($decResult = $this->addDecOrder($insertConId,$insertRecId, $baseInfo['DEC_LV'],$isObserve,$this->remark))) {
                 throw new Exception(Yii::t('app', 'failed'), 400);
             }
+            if ($hasInstalment){ // 如果有分期付款的商品,写入信息至分期付款表
+                $instalmentModel = Instalment::findOne(['USER_ID'=>$userId]);
+                if(!$instalmentModel) {
+                    $instalmentModel = new Instalment();
+                }
+                $instalmentModel->USER_ID = $userId;
+                $instalmentModel->STAGE = $hasInstalment;
+                $instalmentModel->ORDER_TYPE = 'BD';
+                $instalmentModel->UPDATE_TIME = time();
+                $instalmentModel->save();
+            }
         }
         return true;
     }
@@ -300,7 +332,7 @@ class DeclarationUpgradeForm extends Model
                 $transaction->rollBack();
                 throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));
             }
-			
+
             /**
              * 2022-05-10
              * York
@@ -377,7 +409,7 @@ class DeclarationUpgradeForm extends Model
         } catch(Exception $e) {
             $transaction->rollBack();
             throw new Exception($e->getMessage());
-            
+
             return false;
         }
 
@@ -431,7 +463,7 @@ class DeclarationUpgradeForm extends Model
     public function alreadyMaxDec($attribute) {
         $baseInfo = Info::baseInfoZhByUserName($this->insertUserName);
         $userDecId = $baseInfo['DEC_LV'];// 用户当前的级别
-        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref();
         $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
         if ($maxDecId == $userDecId) {
             $this->addError($attribute, 'It is already the highest level and no upgrade is required');//已是最高级别,无需升级
@@ -467,7 +499,7 @@ class DeclarationUpgradeForm extends Model
             }
         }
         unset($allParentUserIds);
-        
+
         return true;
     }
 
@@ -501,4 +533,4 @@ class DeclarationUpgradeForm extends Model
     //     return true;
     // }
 
-}
+}

+ 37 - 4
common/models/forms/OrderForm.php

@@ -11,6 +11,7 @@ use common\helpers\user\Cash;
 use common\helpers\user\Info;
 use common\libs\logging\operate\AdminOperate;
 use common\models\DealType;
+use common\models\Instalment;
 use common\models\Order;
 use common\models\OrderGoods;
 use common\models\Period;
@@ -227,7 +228,7 @@ class OrderForm extends Model
         // 一个订单只能包含一类商品
         $goods = ShopGoods::find()->select('ID,CATEGORY_TYPE')->where(['in', 'ID', $this->goodsId])->andWhere(['STATUS' => 1])->asArray()->all();
         if (!$goods) {
-            throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+            throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
             return;
         }
         $goodsCategoryType = array_unique(array_column($goods, 'CATEGORY_TYPE'));
@@ -463,12 +464,13 @@ class OrderForm extends Model
         $totalAmountStandard = 0;
         $goodsType = ShopGoods::GOODS_TYPE;
         $this->_remainPv = 0;
+        $hasInstalment = 0;
         $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                 if (!$goods) {
-                    throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                    throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                 }
                 if($goods['STORE_NUMS']>0){
                     if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
@@ -530,6 +532,26 @@ class OrderForm extends Model
                         'TAX_RATE' => $goods['TAX_RATE'],
                     ];
                 }
+                if($goods['INSTALMENT']>0){ // 如果有分期付款商品,检查用户的分期付款状态
+                    if($v>1){ // 不可以购买多个
+                        throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                    }
+                    $loginUserId = \Yii::$app->user->id;
+                    $userStage = Instalment::getStage($loginUserId);
+                    $userInstalmentInfo = Instalment::getInfo($loginUserId);
+
+                    if ($userStage != 3){
+                        if($userInstalmentInfo){
+                            if($userInstalmentInfo['STAGE']>0 && $userInstalmentInfo['ORDER_TYPE']!='FX'){
+                                throw new Exception(Yii::t('app', 'canNotBuy'));
+                            }
+                        }
+                        if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
+                            throw new Exception(Yii::t('app', 'canNotBuy'));
+                        }
+                    }
+                    $hasInstalment = $goods['INSTALMENT'];
+                }
             }
         }
 
@@ -570,7 +592,7 @@ class OrderForm extends Model
                 if ($v){
                     $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                     if (!$goods) {
-                        throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                        throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                     }
                     if ($goods['STORE_NUMS'] >= $this->goodsNum[$k]){
                         $data = ShopGoods::find()->where(['ID' => $ids[$k]])->one();
@@ -595,6 +617,17 @@ class OrderForm extends Model
             if (!$orderResult = $this->addOrder()) {
                 throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
             }
+            if ($hasInstalment){ // 如果有分期付款的商品,写入信息至分期付款表
+                $instalmentModel = Instalment::findOne(['USER_ID'=>$loginUserId]);
+                if(!$instalmentModel) {
+                    $instalmentModel = new Instalment();
+                }
+                $instalmentModel->USER_ID = $loginUserId;
+                $instalmentModel->STAGE = $hasInstalment;
+                $instalmentModel->ORDER_TYPE = 'FX';
+                $instalmentModel->UPDATE_TIME = time();
+                $instalmentModel->save();
+            }
 
             $transaction->commit();
 
@@ -876,7 +909,7 @@ class OrderForm extends Model
                 if ($v){
                     $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                     if (!$goods) {
-                        throw new Exception(Yii::t('app', 'productsDoesNotExists'));
+                        throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
                     }
                     if ($goods['STORE_NUMS'] >= $this->goodsNum[$k]){
                         $data = ShopGoods::find()->where(['ID' => $ids[$k]])->one();

+ 5 - 2
common/models/forms/UserForm.php

@@ -240,9 +240,12 @@ class UserForm extends Model
      */
     public function isMinDecLevel($attribute, $params){
         // 获取排序为2的报单级别
-        $decLevel = DeclarationLevel::getLevelFromSort(2);
+        $decLevel = DeclarationLevel::getLevelFromSort(1);
         if($this->zcPv < $decLevel['PERF']){
-            $this->addError($attribute, '注册'.$this->userName.'时,注册PV低于最低级别要求,不能报首购单');
+            if($this->allData['hasInstalment'] && $this->zcPv + 30 >= $decLevel['PERF']){
+            }else{
+                $this->addError($attribute, '注册'.$this->userName.'时,注册PV低于最低级别要求,不能报首购单');
+            }
         }
     }
 

+ 3 - 3
frontendApi/config/menu.php

@@ -34,8 +34,8 @@ return [
 //            ['name'=>'Repeat sales products', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],//复消商品
 //            ['name'=>'申请退货', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-backing-out', 'routePath'=>'shop/order-backing-out', 'show'=>1,],//申请退货
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],//订单列表
-            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer',],
-            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer',],
+//            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer',],
+//            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer',],
         ]
     ],
     'user'=>[
@@ -66,7 +66,7 @@ return [
         'child'=>[
             ['name'=>'Placement network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1,],
             ['name'=>'Sponsor network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation', 'routePath'=>'atlas/relation', 'show'=>1,],
-            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'brand-ambassador-list', 'routePath'=>'atlas/brand-ambassador-list', 'show'=>1,],
+//            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'brand-ambassador-list', 'routePath'=>'atlas/brand-ambassador-list', 'show'=>1,],
         ]
     ],
     'bonus'=>[

+ 3 - 3
frontendApi/config/menuV2.php

@@ -30,8 +30,8 @@ return [
             ['name'=>'Welcome Pack Listing', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1, 'wiki' => 'welcomePackList',],//报单列表
             ['name'=>'Upgrade Management', 'class'=>'', 'icon'=>'', 'controller'=>'upgrade', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer', 'wiki' => 'memberUpgrade',],//升级管理
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1, 'wiki' => 'orderList',],//订单列表
-            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer', 'wiki' => 'brandAmbassador',],// BA会员
-            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer', 'wiki' => 'BAOrderList',],// BA订单
+//            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer', 'wiki' => 'brandAmbassador',],// BA会员
+//            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer', 'wiki' => 'BAOrderList',],// BA订单
         ]
     ],
     'user'=>[
@@ -60,7 +60,7 @@ return [
         'child'=>[
             ['name'=>'Placement Network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1, 'wiki' => 'placementNetwork',],//安置网络
             ['name'=>'Sponsor Network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation', 'routePath'=>'atlas/relation', 'show'=>1, 'wiki' => 'sponsorNetwork',],//推荐网路
-            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'brand-ambassador-list', 'routePath'=>'atlas/brand-ambassador-list', 'show'=>1, 'wiki' => 'brandAmbassadorList',],// BA会员
+//            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'brand-ambassador-list', 'routePath'=>'atlas/brand-ambassador-list', 'show'=>1, 'wiki' => 'brandAmbassadorList',],// BA会员
         ]
     ],
     'bonus'=>[

+ 1 - 1
frontendApi/modules/v1/controllers/BonusController.php

@@ -228,7 +228,7 @@ class BonusController extends BaseController {
                 $condition.=' AND IS_INCR=1 AND DEAL_TYPE_IS_PRESET=0';
             }elseif ($dealType==2){//扣除
                 $condition.=' AND IS_INCR=0 AND DEAL_TYPE_IS_PRESET=0';
-            }else{
+            }else if ($walletType != 'cash') {
                 $condition.=' AND DEAL_TYPE_ID=:DEAL_TYPE';
                 $params[':DEAL_TYPE'] = $dealType;
             }

+ 15 - 7
frontendApi/modules/v1/controllers/UserController.php

@@ -28,6 +28,7 @@ use common\models\forms\BaDeclarationLoopForm;
 use common\models\forms\UploadForm;
 use common\models\forms\UserBindForm;
 use common\models\forms\UserForm;
+use common\models\Instalment;
 use common\models\OpenBank;
 use common\models\ReceiveAddress;
 use common\models\Region;
@@ -239,7 +240,7 @@ class UserController extends BaseController {
         // 获取系统中的DEC 报单级别配置
         $decConfig = Cache::getDecLevelConfig();
         $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
-        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref();
         $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
         $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
         $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
@@ -258,7 +259,7 @@ class UserController extends BaseController {
             'IS_OBSERVE' => $isObserve, // 是否是观察期  true为是观察期
             'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
         ];
-        
+
         // 如果是最高级别了,则无需升级
         if ($isMax) {
             return static::notice(['baseInfo' => $userInfo]);
@@ -286,15 +287,22 @@ class UserController extends BaseController {
             $userInfo['NEXT_PERF'] =  $nextLevelPerf;
             // 用户可选择的级别列表
             $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll($levelPerf);// 用户可选择的级别列表
+            // 如果用户正处于报单分期中,则可以升级到Elite
+            $userInstalmentInfo = Instalment::getInfo($userId);
+            if($userInstalmentInfo){
+                if ($userInstalmentInfo['ORDER_TYPE']=='BD' && $userInstalmentInfo['STAGE'] < 3){
+                    $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll(12);// 用户可选择的级别列表
+                }
+            }
             // 循环列表,补充升级所需要的补差
             foreach ($userInfo['LEVEL_LIST'] as &$v) {
                 $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
-            }   
+            }
         }
-        
+
         return static::notice(['baseInfo' => $userInfo]);
     }
-    
+
     // 会员升级管理
     public function actionUpgrade() {
         $isSwitchUpgrade = Config::find()
@@ -642,7 +650,7 @@ class UserController extends BaseController {
         }
         return static::notice(Yii::t('app', 'illegalRequest'), 400);
     }
-    
+
     /**
      * BA报单管理
      */
@@ -744,4 +752,4 @@ class UserController extends BaseController {
             return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
         }
     }
-}
+}

+ 11 - 11
frontendApi/modules/v1/models/LoginForm.php

@@ -178,17 +178,17 @@ class LoginForm extends Model
                     'BONUS_APP_CLIENT_ID' => $clientId,
                 ];
 
-                if (!$this->_whetherBA) {
+//                if (!$this->_whetherBA) {
                     if (!User::updateAll($update, 'ID=:ID', ['ID' => $this->_user['ID']])) {
                         $this->_updateFailTimes($transaction, Yii::t('app', 'memberAppDeviceInformationUpdateFailed'));
                         throw new Exception(Yii::t('app', 'memberAppDeviceInformationUpdateFailed'));
                     }
-                } else {
-                    if (!BaUser::updateAll($update, 'ID=:ID', ['ID' => $this->_user['ID']])) {
-                        $this->_updateFailTimes($transaction, Yii::t('app', 'memberAppDeviceInformationUpdateFailed'));
-                        throw new Exception(Yii::t('app', 'memberAppDeviceInformationUpdateFailed'));
-                    }
-                }
+//                } else {
+//                    if (!BaUser::updateAll($update, 'ID=:ID', ['ID' => $this->_user['ID']])) {
+//                        $this->_updateFailTimes($transaction, Yii::t('app', 'memberAppDeviceInformationUpdateFailed'));
+//                        throw new Exception(Yii::t('app', 'memberAppDeviceInformationUpdateFailed'));
+//                    }
+//                }
             }
 
 
@@ -200,11 +200,11 @@ class LoginForm extends Model
             // 把用户的登录时间存在操作时间里
             Yii::$app->tokenRedis->hset('user:timeOut', $this->_userInfo['USER_ID'], time());
 
-            if (!$this->_whetherBA) {
+//            if (!$this->_whetherBA) {
                 return Yii::$app->user->loginWithUAndP($this->_user);
-            } else {
-                return Yii::$app->brand->loginWithUAndP($this->_user);
-            }
+//            } else {
+//                return Yii::$app->brand->loginWithUAndP($this->_user);
+//            }
         }catch(\Exception $e){
             $transaction->rollBack();
 //            $this->setError($e->getFile() . '  ' . $e->getLine() . '  ' . $e->getMessage());