Эх сурвалжийг харах

预充值存款合作伙伴权限

qzyReal 2 жил өмнө
parent
commit
c4bc696bb8
17 өөрчлөгдсөн 207 нэмэгдсэн , 67 устгасан
  1. 1 10
      sp-admin/sa-view/tb-business-car/tb-business-car-list.html
  2. 2 2
      sp-admin/sa-view/tb-business/tb-car-disincle-info.html
  3. 36 4
      sp-admin/sa-view/tb-business/tb-car-disincle-list.html
  4. 25 1
      sp-admin/sa-view/tb-deduction-record/tb-deduction-record-list.html
  5. 17 17
      sp-server/src/main/java/com/pj/api/open/service/OpenService.java
  6. 6 4
      sp-server/src/main/java/com/pj/project/tb_account/AutomaticPay.java
  7. 12 0
      sp-server/src/main/java/com/pj/project/tb_account/TbAccountController.java
  8. 1 1
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java
  9. 1 0
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.xml
  10. 48 11
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java
  11. 13 1
      sp-server/src/main/java/com/pj/project/tb_deduction_record/TbDeductionRecordController.java
  12. 7 2
      sp-server/src/main/java/com/pj/project/tb_deduction_record/TbDeductionRecordMapper.xml
  13. 19 13
      sp-server/src/main/java/com/pj/project/tb_deduction_record/TbDeductionRecordService.java
  14. 1 1
      sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java
  15. 4 0
      sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrder.java
  16. 5 0
      sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrderService.java
  17. 9 0
      sp-server/src/main/java/com/pj/project/tb_refund_record/TbRefundRecordController.java

+ 1 - 10
sp-admin/sa-view/tb-business-car/tb-business-car-list.html

@@ -68,16 +68,7 @@
 							<el-option label="免费车" value="1"></el-option>
 						</el-select>
 					</div>
-					<div class="c-item">
-						<label class="c-label">审核状态:</label>
-						<el-select v-model="p.confirmJudge">
-							<el-option label="全部" value=""></el-option>
-							<el-option label="未审核" :value="0"></el-option>
-							<el-option label="审核通过" :value="1"></el-option>
-							<el-option label="审核驳回" :value="2"></el-option>
-							<el-option label="无需审核" :value="3"></el-option>
-						</el-select>
-					</div>
+				
 					<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
 					<el-button size="mini" type="primary" @click="exportFn" v-if="sa.isAuth('tb-business-car-export')">
 						导出

+ 2 - 2
sp-admin/sa-view/tb-business/tb-car-disincle-info.html

@@ -176,10 +176,10 @@
 			<!-- ------- 底部按钮 ------- -->
 			<div class="s-foot">
 				<!-- <el-button class="c-btn" type="success" icon="el-icon" @click="print()">打印单据</el-button> -->
-				<el-button v-if="sa.isAuth('tb-flex-business-judge')&&m.confirmJudge!=1"
+				<!-- <el-button v-if="sa.isAuth('tb-flex-business-judge')&&m.confirmJudge!=1"
 					class="c-btn" type="success" icon="el-icon" @click="pass()">审核通过</el-button>
 				<el-button v-if="sa.isAuth('tb-flex-business-judge')&&m.confirmJudge==1"
-					class="c-btn" type="warning" icon="el-icon" @click="callback()">审核驳回</el-button>
+					class="c-btn" type="warning" icon="el-icon" @click="callback()">审核驳回</el-button> -->
 				<el-button type="success" @click="sa.closeCurrIframe()">关闭</el-button>
 			</div>
 

+ 36 - 4
sp-admin/sa-view/tb-business/tb-car-disincle-list.html

@@ -43,14 +43,14 @@
 					<sa-item type="text" name="车牌号" placeholder="车牌号" v-model="p.carNo"></sa-item>
 					<sa-item type="text" name="客户" placeholder="客户" v-model="p.customerName"></sa-item>
 					<sa-item type="text" name="合作伙伴" placeholder="合作伙伴" v-model="p.pickCustomerName"></sa-item>
-					<div class="c-item">
+					<!-- <div class="c-item">
 						<label class="c-label">确认状态:</label>
 						<el-select v-model="p.adminConfirmInput" placeholder="请选择" @change="f5()">
 							<el-option label="全部" :value="-1"></el-option>
 							<el-option label="已确认" :value="1"></el-option>
 							<el-option label="未确认" :value="0"></el-option>
 						</el-select>
-					</div>
+					</div> -->
 					<div class="c-item">
 						<label class="c-label">状态:</label>
 						<el-select v-model="p.hasError" placeholder="请选择" @change="f5()">
@@ -66,10 +66,19 @@
 							</el-option>
 						</el-select>
 					</div>
+					<div class="c-item">
+						<label class="c-label">审核状态:</label>
+						<el-select v-model="p.confirmJudge">
+							<el-option label="全部" value=""></el-option>
+							<el-option label="未审核" :value="0"></el-option>
+							<el-option label="审核通过" :value="1"></el-option>
+							<el-option label="审核驳回" :value="2"></el-option>
+						</el-select>
+					</div>
 					<div>
 						<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
 						<el-button type="info" icon="el-icon-search"
-							@click="p.carNo = '';p.adminConfirmInput=-1;p.customerName='';p.pickCustomerName='';p.owner='';p.no=''; f5()">
+							@click="p.carNo = '';p.confirmJudge='';p.customerName='';p.pickCustomerName='';p.owner='';p.no=''; f5()">
 							重置
 						</el-button>
 						<el-button v-if="sa.isAuth('tb-flex-business-add')" size="mini" type="primary" @click="add()">
@@ -110,6 +119,8 @@
 									&&currentCustomerId=='1'&&s.row.adminConfirmInput==1" @click="checkConfirmFn(s.row)">查看账单
 							</el-button>
 							<el-button class="c-btn" type="success" @click="get(s.row)">查看</el-button>
+							<el-button class="c-btn" type="success" v-if="sa.isAuth('tb-flex-business-judge')&&s.row.confirmJudge!=1" @click="pass(s.row)">审核</el-button>
+							<el-button class="c-btn" type="warning" v-if="sa.isAuth('tb-flex-business-judge')&&s.row.confirmJudge==1" @click="callback(s.row)">驳回</el-button>
 							<el-button class="c-btn" type="primary"
 								v-if="currentCustomerId=='1'||(s.row.adminConfirmInput==0&&sa.isAuth('tb-flex-business-edit'))"
 								@click="update(s.row)">
@@ -233,7 +244,28 @@
 					goodsList: [],
 				},
 				methods: {
-					
+					pass(data) {
+						sa.ajax('/TbBusiness/confirmJudgePass', {
+							id: data.id
+						}, function(res) {
+							sa.alert('审核通过', this.f5);
+						}.bind(this))
+					},
+					callback(data) {
+						let that = this;
+						console.log(data);
+						layer.prompt({
+							title: '填写驳回原因'
+						}, function(content, index) {
+							layer.close(index);
+							sa.ajax('/TbBusiness/callback', {
+								id: data.id,
+								judgeContent: content
+							}, function(res) {
+								sa.alert('已驳回', that.f5);
+							})
+						});
+					},
 					sureAddFn() {
 
 					},

+ 25 - 1
sp-admin/sa-view/tb-deduction-record/tb-deduction-record-list.html

@@ -54,7 +54,7 @@
 							</el-option>
 						</el-select>
 					</sa-item>
-					<sa-item type="text" name="支付时间">
+					<sa-item type="text" name="扣款时间">
 						<el-date-picker v-model="p.payTime" type="daterange" align="right" unlink-panels
 							value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期"
 							end-placeholder="结束日期" :picker-options="pickerOptions">
@@ -239,11 +239,27 @@
 				},
 				methods: {
 					getSum(){
+						let p=this.p;
+						if(p.payTime){
+							p.startTime=p.payTime[0];
+							p.endTime=p.payTime[1];
+						}else{
+							p.startTime='';
+							p.endTime='';
+						}
 						sa.ajax('/TbDeductionRecord/getSum', sa.removeNull(this.p), function(res) {
 							this.totalMoney=res.data;
 						}.bind(this));
 					},
 					exportFn () {
+						let p=this.p;
+						if(p.payTime){
+							p.startTime=p.payTime[0];
+							p.endTime=p.payTime[1];
+						}else{
+							p.startTime='';
+							p.endTime='';
+						}
 						sa.confirm('是否导出符合筛选条件的扣费记录', function() {
 							sa.ajax('/TbDeductionRecord/export', sa.removeNull(this.p),
 								function(res) {
@@ -268,6 +284,14 @@
 					},
 					// 刷新
 					f5: function() {
+						let p=this.p;
+						if(p.payTime){
+							p.startTime=p.payTime[0];
+							p.endTime=p.payTime[1];
+						}else{
+							p.startTime='';
+							p.endTime='';
+						}
 						sa.ajax('/TbDeductionRecord/getList', sa.removeNull(this.p), function(res) {
 							this.dataList = res.data; // 数据
 							this.dataCount = res.dataCount; // 数据总数 

+ 17 - 17
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -195,19 +195,19 @@ public class OpenService {
         List<IOrderItem> expenses = new ArrayList<>();
         List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(businessCarId);
         long judgeCount = businessList.stream().filter(tbBusiness -> tbBusiness.getConfirmJudge() == CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()).count();
-        int size=businessList.size();
-        if (size>judgeCount){
+        int size = businessList.size();
+        if (size > judgeCount) {
             //业务未审核完
             log.error("请求返回【业务未审核】:{}", carNo);
             return ResultJson.error("业务未审核");
         }
-        BigDecimal hasPayPartMoney=tbBusinessCar.getMoney();
+        BigDecimal hasPayPartMoney = tbBusinessCar.getMoney();
         if (businessList.isEmpty()) {
             //无业务车辆===>计算停车费
             //如果已经支付过,则从支付时间算起,重新计算停车费
-            Date inTime=tbBusinessCar.getRealInTime();
-            if (hasPayPartMoney.compareTo(BigDecimal.ZERO)>0){
-                inTime=now;
+            Date inTime = tbBusinessCar.getRealInTime();
+            if (hasPayPartMoney.compareTo(BigDecimal.ZERO) > 0) {
+                inTime = now;
             }
             IOrderPriceRes res = tbBusinessService.getPartMoney(inTime, now, carNo, tbBusinessCar.getColor());
             double dif = res.getTotalOrderPrice().subtract(tbBusinessCar.getMoney()).doubleValue();
@@ -227,16 +227,16 @@ public class OpenService {
         } else {
             //有业务的车--->都要交停车费
             //该车所有的业务都是到达卡口才进行扣费才会进入自动扣费
-            Date inTime=tbBusinessCar.getRealInTime();
-            if (hasPayPartMoney.compareTo(BigDecimal.ZERO)>0){
-                inTime=now;
+            Date inTime = tbBusinessCar.getRealInTime();
+            if (hasPayPartMoney.compareTo(BigDecimal.ZERO) > 0) {
+                inTime = now;
             }
             partMoneyRes = tbBusinessService.getPartMoney(inTime, now, carNo, tbBusinessCar.getColor());
             double dif = partMoneyRes.getTotalOrderPrice().doubleValue();
             if (dif > 0) {
                 RedisUtil.setByMINUTES(channel, carNo, 5);
                 log.error("停车费:{},{}元", carNo, dif);
-            }else {
+            } else {
                 if (tbBusinessCar.getPayTime() == null) {
                     tbBusinessCar.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType()).setPay(1);
                 }
@@ -291,13 +291,13 @@ public class OpenService {
                 desc += " 停车费" + carMoney.toString() + "元";
             }
             RedisUtil.setByMINUTES(channel, carNo, 5);
-            boolean flag = automaticPay.payBusinessAndPartMoney(businessList, tbBusinessCar, partMoneyRes);
-            if (flag) {
-                //
-                log.error("预存款扣款成功,返回:{},{}", carNo, desc);
-                freeOut(tbBusinessCar, now, channel, image);
-                return ResultJson.success();
-            }
+            // boolean flag = automaticPay.payBusinessAndPartMoney(businessList, tbBusinessCar, partMoneyRes);
+            //  if (flag) {
+            //
+            //   log.error("预存款扣款成功,返回:{},{}", carNo, desc);
+            //    freeOut(tbBusinessCar, now, channel, image);
+            //   return ResultJson.success();
+            //  }
             log.error("请求返回:{},{}", carNo, desc);
             return ResultJson.error(desc);
         }

+ 6 - 4
sp-server/src/main/java/com/pj/project/tb_account/AutomaticPay.java

@@ -2,6 +2,7 @@ package com.pj.project.tb_account;
 
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
@@ -103,7 +104,7 @@ public class AutomaticPay {
     /**
      * 生成扣费记录
      */
-    public void createTbDeductionRecord(TbFeeDetails feeDetails, BigDecimal originalMoney, BigDecimal balance,
+    public TbDeductionRecord createTbDeductionRecord(TbFeeDetails feeDetails, BigDecimal originalMoney, BigDecimal balance,
                                         String customerId,String customerName,String plate, String businessCarId, FeeTypeEnum feeTypeEnum) {
         TbDeductionRecord deductionRecord = BeanUtil.toBean(feeDetails, TbDeductionRecord.class);
         BigDecimal itemPrice = feeDetails.getItemPrice();
@@ -120,11 +121,12 @@ public class AutomaticPay {
                 .setReviewStatus(0).setFeeType(feeTypeEnum.getCode()).setFeeTypeName(feeTypeEnum.getDesc())
                 .setCarNo(plate).setBusinessItemId(feeDetails.getBusinessItemId())
                 .setFeeDetailsId(feeDetails.getId())
-                .setBusinessNo(feeDetails.getBusinessNo())
-                .setPreOrderNum(no);
+                .setBusinessNo(feeDetails.getBusinessNo());
         deductionRecord.insert();
-        feeDetails.setPreOrderNum(no);
+        String preNo= DateUtil.format(new Date(),"yyyyMMddHHmm")+RandomUtil.randomString(5);
+        feeDetails.setPreOrderNum(preNo);
         tbFeeDetailsService.updateById(feeDetails);
+        return deductionRecord;
     }
 
     /**

+ 12 - 0
sp-server/src/main/java/com/pj/project/tb_account/TbAccountController.java

@@ -55,6 +55,10 @@ public class TbAccountController {
     @SaCheckPermission(TbAccount.TB_ACCOUNT_BALANCE_LIST)
     public AjaxJson getBalance() {
         SoMap soMap = SoMap.getRequestSoMap();
+        String currentCustomerId = StpUserUtil.getCustomerId();
+        if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+            soMap.put("customerId", currentCustomerId);
+        }
         Page<TbBalanceBO> page = tbAccountService.getBalancePage(soMap);
         return AjaxJson.getPageData(page.getSize(), page.getRecords());
     }
@@ -70,12 +74,20 @@ public class TbAccountController {
     @SaCheckPermission(TbAccount.TB_ACCOUNT_BALANCE_LIST)
     public AjaxJson export() {
         SoMap soMap = SoMap.getRequestSoMap();
+        String currentCustomerId = StpUserUtil.getCustomerId();
+        if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+            soMap.put("customerId", currentCustomerId);
+        }
         return AjaxJson.getSuccessData(tbAccountService.export(soMap));
     }
     @RequestMapping(value = "getSum")
     @SaCheckPermission(TbAccount.TB_ACCOUNT_BALANCE_LIST)
     public AjaxJson getSum() {
         SoMap soMap = SoMap.getRequestSoMap();
+        String currentCustomerId = StpUserUtil.getCustomerId();
+        if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+            soMap.put("customerId", currentCustomerId);
+        }
         return AjaxJson.getSuccessData(tbAccountService.getSum(soMap));
     }
 

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java

@@ -407,7 +407,7 @@ public class TbBusinessController {
         SoMap soMap = SoMap.getRequestSoMap();
         String id = soMap.getString("id");
         String judgeContent = soMap.getString("judgeContent");
-        tbBusinessCarService.callback(id,judgeContent);
+        tbBusinessService.callback(id,judgeContent);
         return AjaxJson.getSuccess();
     }
 }

+ 1 - 0
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.xml

@@ -22,6 +22,7 @@
             <if test=' this.has("businessGoodsName") '>and business_goods_name like concat('%', #{businessGoodsName},'%')</if>
             <if test=' this.has("cardNo") '>and card_no like concat('%', #{cardNo} ,'%')</if>
             <if test=' this.has("cardSize") '>and card_size = #{cardSize}</if>
+            <if test=' this.has("confirmJudge") '>and confirm_judge = #{confirmJudge}</if>
             <if test=' this.has("netWeight") '>and net_weight = #{netWeight}</if>
             <if test=' this.has("goodsId") '>and goods_id = #{goodsId}</if>
             <if test=' this.has("goodsName") '>and goods_name = #{goodsName}</if>

+ 48 - 11
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -62,6 +62,7 @@ import com.pj.project.tb_declare.TbDeclare;
 import com.pj.project.tb_declare.TbDeclareService;
 import com.pj.project.tb_deduction_bind.TbDeductionBind;
 import com.pj.project.tb_deduction_bind.TbDeductionBindService;
+import com.pj.project.tb_deduction_record.TbDeductionRecord;
 import com.pj.project.tb_driver.TbDriver;
 import com.pj.project.tb_driver.TbDriverService;
 import com.pj.project.tb_fee_details.TbFeeDetails;
@@ -69,6 +70,8 @@ import com.pj.project.tb_fee_details.TbFeeDetailsService;
 import com.pj.project.tb_fee_statistics.TbFeeStatisticsService;
 import com.pj.project.tb_goods.TbGoods;
 import com.pj.project.tb_goods.TbGoodsService;
+import com.pj.project.tb_invoice_order.TbInvoiceOrder;
+import com.pj.project.tb_invoice_order.TbInvoiceOrderService;
 import com.pj.project.tb_item.TbItem;
 import com.pj.project.tb_item.TbItemService;
 import com.pj.project.tb_item_fac.TbItemFac;
@@ -178,7 +181,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     private TbFeeDetailsService tbFeeDetailsService;
 
     @Resource
-    private TbDeductionBindService tbDeductionBindService;
+    private TbInvoiceOrderService tbInvoiceOrderService;
     @Resource
     @Lazy
     private TbFeeStatisticsService tbFeeStatisticsService;
@@ -457,10 +460,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         List<String> businessIdList = businessList.stream().map(TbBusiness::getId).collect(Collectors.toList());
         String businessIds = StrUtil.join(",", businessIdList);
         long judgeCount = businessList.stream().filter(tbBusiness -> tbBusiness.getConfirmJudge() == CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()).count();
-        int size=businessList.size();
+        int size = businessList.size();
         result.put("showPay", true);
         result.put("businessId", businessIds);
-        result.put("noJudgeCount", judgeCount==size?0:1);
+        result.put("noJudgeCount", judgeCount == size ? 0 : 1);
         List<TbBusinessItem> items = tbBusinessItemService.findByBusinessIdList(businessIdList);
         Date inTime = tbBusinessCar.getRealInTime();
         int pay = tbBusinessCar.getPay();
@@ -835,7 +838,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         if (dbBusiness == null) {
             throw new AjaxError("记录不存在");
         }
-        if (dbBusiness.getConfirmJudge()== CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()){
+        if (dbBusiness.getConfirmJudge() == CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()) {
             throw new AjaxError("业务已审核,请驳回后修改");
         }
         List<TbItem> tbItems = otherBusinessBO.getItems();
@@ -993,7 +996,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 
     public void bindOtherBusinessCar(String businessId, List<String> businessCarIdList) {
         TbBusiness tbBusiness = this.getById(businessId);
-        if (tbBusiness.getConfirmJudge()== CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()){
+        if (tbBusiness.getConfirmJudge() == CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()) {
             throw new AjaxError("业务已审核,请先驳回");
         }
         List<TbBusinessCar> list = tbBusinessCarService.findOtherBusinessCar(businessId);
@@ -1524,7 +1527,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     public void addBusinessCar(TbBusinessCar tbBusinessCar) {
         String businessId = tbBusinessCar.getBusinessId();
         TbBusiness tbBusiness = this.getById(businessId);
-        if (tbBusiness.getConfirmJudge()== CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()){
+        if (tbBusiness.getConfirmJudge() == CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()) {
             throw new AjaxError("业务已审核,不能绑定新车辆");
         }
         String carNo = tbBusinessCar.getCarNo().trim().toUpperCase();
@@ -1578,6 +1581,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         }
     }
 
+    /**
+     * 审核通过
+     * @param id
+     */
     public void confirmJudgePass(String id) {
         TbBusiness tbBusiness = this.getById(id);
         if (tbBusiness == null) {
@@ -1616,13 +1623,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         tbAccountService.updateById(tbAccount);
                         TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, FeeTypeEnum.STEVEDORE_FEE);
                         tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
-                        automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
+                        TbDeductionRecord record=  automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
+                        addInvoiceOrder(tbBusiness, res.getTotalOrderPrice(),details,record);
                     }
                 }
             }
         }
-
-
         //其他费项 装卸业务管理费” 进行预存款扣除
         for (TbBusinessItem item : tbBusinessItems) {
             //业务类型是装卸业务管理费且未支付的进行扣款
@@ -1650,15 +1656,46 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                             .findAny().orElse(tbBusinessCars.get(0));
                     TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, FeeTypeEnum.STEVEDORE_FEE);
                     tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
-                    automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
+                    TbDeductionRecord record=  automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
+                    addInvoiceOrder(tbBusiness, res.getTotalOrderPrice(),details,record);
                 }
             }
         }
-
         tbBusiness.setConfirmJudgeTime(now).setConfirmJudgeContent("审核通过")
                 .setConfirmJudge(CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode())
                 .setJudgeBy(StpUserUtil.getCreateBy()).setPayTime(now);
         this.updateById(tbBusiness);
+    }
 
+    /**
+     * 添加开票订单
+     * @param tbBusiness
+     * @param billMoney
+     */
+    private void addInvoiceOrder(TbBusiness tbBusiness, BigDecimal billMoney,TbFeeDetails details,TbDeductionRecord record) {
+        TbInvoiceOrder t = new TbInvoiceOrder();
+        t.setBusinessName(tbBusiness.getGoodsName())
+                .setBusinessNo(tbBusiness.getNo())
+                .setCarNo(tbBusiness.getCarNoStr())
+                .setBusinessId(tbBusiness.getId())
+                .setCustomerId(tbBusiness.getCustomerId())
+                .setBillMoney(billMoney).setDetailId(details.getId())
+                .setPreOrderNum(details.getPreOrderNum())
+                .setDeductionRecordId(record.getId())
+                .setStatus(0).setCreateTime(new Date());
+        tbInvoiceOrderService.save(t);
+    }
+
+    /**
+     * 审核驳回
+     * @param id
+     * @param judgeContent
+     */
+    public void callback(String id, String judgeContent) {
+        TbBusiness db = this.getById(id);
+        db.setConfirmJudge(CarEnum.ConfirmJudgeEnum.CALL_BACK.getCode())
+                .setConfirmJudgeContent(judgeContent).setConfirmJudgeTime(new Date())
+                .setJudgeBy(StpUserUtil.getCreateBy());
+        this.updateById(db);
     }
 }

+ 13 - 1
sp-server/src/main/java/com/pj/project/tb_deduction_record/TbDeductionRecordController.java

@@ -1,6 +1,7 @@
 package com.pj.project.tb_deduction_record;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.pj.constants.UserTypeEnum;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.project.tb_charge_record.TbChargeRecord;
 import com.pj.project4sp.SP;
@@ -49,6 +50,10 @@ public class TbDeductionRecordController {
 	@RequestMapping("getList")
 	public AjaxJson getList() { 
 		SoMap so = SoMap.getRequestSoMap();
+		String currentCustomerId = StpUserUtil.getCustomerId();
+		if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+			so.put("customerId", currentCustomerId);
+		}
 		List<TbDeductionRecord> list = tbDeductionRecordService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
@@ -85,14 +90,21 @@ public class TbDeductionRecordController {
 	@SaCheckPermission(TbDeductionRecord.PERMISSION_LIST_EXPORT)
 	public AjaxJson export() {
 		SoMap so = SoMap.getRequestSoMap();
+		String currentCustomerId = StpUserUtil.getCustomerId();
+		if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+			so.put("customerId", currentCustomerId);
+		}
 		String url = tbDeductionRecordService.export(so);
 		return AjaxJson.getSuccessData(url);
 	}
 
 	@RequestMapping("getSum")
-	@SaCheckPermission(TbDeductionRecord.PERMISSION_LIST_EXPORT)
 	public AjaxJson getSum() {
 		SoMap so = SoMap.getRequestSoMap();
+		String currentCustomerId = StpUserUtil.getCustomerId();
+		if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+			so.put("customerId", currentCustomerId);
+		}
 		return AjaxJson.getSuccessData(tbDeductionRecordService.getSum(so));
 	}
 	

+ 7 - 2
sp-server/src/main/java/com/pj/project/tb_deduction_record/TbDeductionRecordMapper.xml

@@ -151,6 +151,7 @@
 		<where>
 			<if test=' this.has("id") '> and id = #{id} </if>
 			<if test=' this.has("businessId") '> and business_id = #{businessId} </if>
+			<if test=' this.has("customerId") '> and customer_id = #{customerId} </if>
 			<if test=' this.has("status") and status !=-1 '> and status = #{status} </if>
 			<if test=' this.has("businessNo") '> and business_no like "%" #{businessNo} "%" </if>
 			<if test=' this.has("carNo") '> and car_no like "%" #{carNo} "%" </if>
@@ -195,8 +196,12 @@
 			<if test=' this.has("originalMoney") '> and original_money = #{originalMoney} </if>
 			<if test=' this.has("totalMoney") '> and total_money = #{totalMoney} </if>
 			<if test=' this.has("reviewStatus") and reviewStatus!=2 '> and review_status = #{reviewStatus} </if>
-			<if test=' this.has("startTime") '> and date(pay_time) between #{startTime} and #{endTime} </if>
-
+			<if test=' this.has("startTime") '>
+			 and date_format(pay_time,'%Y-%m-%d') &gt;=#{startTime}
+			  </if>
+			<if test=' this.has("endTime") '>
+				and date_format(pay_time,'%Y-%m-%d') &lt;=#{endTime}
+			</if>
 		</where>
 		order by
 		<choose>

+ 19 - 13
sp-server/src/main/java/com/pj/project/tb_deduction_record/TbDeductionRecordService.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.RandomUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
@@ -26,6 +27,9 @@ import com.pj.project.tb_business_item.TbBusinessItemService;
 import com.pj.project.tb_charge_record.TbChargeRecord;
 import com.pj.project.tb_charge_record.TbChargeRecordMapper;
 import com.pj.project.tb_charge_record.TbChargeRecordService;
+import com.pj.project.tb_invoice_info.TbInvoiceInfoService;
+import com.pj.project.tb_invoice_order.TbInvoiceOrder;
+import com.pj.project.tb_invoice_order.TbInvoiceOrderService;
 import com.pj.project.tb_mild_car.TbMildCar;
 import com.pj.project.tb_refund_record.TbRefundRecord;
 import com.pj.project.tb_refund_record.TbRefundRecordService;
@@ -74,6 +78,10 @@ public class TbDeductionRecordService extends ServiceImpl<TbDeductionRecordMappe
     private TbRefundRecordService tbRefundRecordService;
     @Resource
     private UploadConfig uploadConfig;
+    @Resource
+    private TbInvoiceOrderService tbInvoiceOrderService;
+    @Resource
+    private TbInvoiceInfoService tbInvoiceInfoService;
 
     /**
      * 增
@@ -112,17 +120,6 @@ public class TbDeductionRecordService extends ServiceImpl<TbDeductionRecordMappe
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
     List<TbDeductionRecord> getList(SoMap so) {
-        String customerId = StpUserUtil.getCustomerId();
-        if (!UserTypeEnum.PLATFORM_ADMIN.getCustomerId().equals(customerId)) {
-            so.put("customerId", customerId);
-        }
-        if (ObjectUtil.isNotEmpty(so.get("parTime[]"))) {
-            JSONArray jsonArray = JSONUtil.parseArray(so.getString("parTime[]"));
-            if (jsonArray.size() == 2) {
-                so.put("startTime", jsonArray.get(0));
-                so.put("endTime", jsonArray.get(1));
-            }
-        }
         return tbDeductionRecordMapper.getList(so);
     }
 
@@ -144,6 +141,14 @@ public class TbDeductionRecordService extends ServiceImpl<TbDeductionRecordMappe
         if (record == null) {
             throw new AjaxError("记录不存在");
         }
+        TbInvoiceOrder order = tbInvoiceOrderService.findByRecord(record.getId());
+        if (order != null) {
+            if ((order.getStatus() == 2 || StrUtil.isNotEmpty(order.getInfoId()))) {
+                throw new AjaxError("订单已开发票,不允许设置为异常单");
+            }
+            tbInvoiceOrderService.removeById(order.getId());
+            tbInvoiceInfoService.removeById(order.getInfoId());
+        }
         String businessId = record.getBusinessId();
         TbBusiness tbBusiness = tbBusinessService.getById(businessId);
         tbBusiness.setHasError(1);
@@ -232,7 +237,8 @@ public class TbDeductionRecordService extends ServiceImpl<TbDeductionRecordMappe
     }
 
     /**
-     *某个时间段的扣款记录
+     * 某个时间段的扣款记录
+     *
      * @param eDay
      * @return
      */
@@ -266,6 +272,6 @@ public class TbDeductionRecordService extends ServiceImpl<TbDeductionRecordMappe
 
     public Double getSum(SoMap so) {
         List<TbDeductionRecord> list = tbDeductionRecordMapper.getList(so);
-        return   list.stream().collect(Collectors.summarizingDouble(record->record.getDeductMoney().doubleValue())).getSum();
+        return list.stream().collect(Collectors.summarizingDouble(record -> record.getDeductMoney().doubleValue())).getSum();
     }
 }

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java

@@ -528,7 +528,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
                     .setFeeType(tbFeeItem.getName()).setItemTypeName(feeDetails.getItemTypeName())
                     .setItemName(feeDetails.getItemName()).setItemPrice(feeDetails.getItemPrice())
                     .setPayType(PayEnum.PayType.getDescByCode(feeDetails.getPayType())).setIndex(index++)
-                    .setPayMode("直接收款")
+                    .setPayMode(PayEnum.PayType.getDescByCode(feeDetails.getPayType()))
                     .setWeight(feeDetails.getWeight()).setNum(feeDetails.getNum()).setUnitPrice(feeDetails.getUnitPrice())
                     .setSettle("已结算").setTaxRate(feeDetails.getTaxRate().multiply(new BigDecimal(100)))
                     .setTaxPrice(feeDetails.getTaxPrice()).setNoTaxPrice(feeDetails.getNoTaxPrice()).setPayTime(feeDetails.getPayTime())

+ 4 - 0
sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrder.java

@@ -112,6 +112,10 @@ public class TbInvoiceOrder implements Serializable {
      * 开票信息明细Id
      */
     public String detailId;
+	/**
+	 * 扣费记录ID
+	 */
+	public String deductionRecordId;
 
 
 

+ 5 - 0
sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrderService.java

@@ -326,4 +326,9 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
         return list(ew);
     }
 
+    public TbInvoiceOrder findByRecord(String recordId) {
+        QueryWrapper<TbInvoiceOrder> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbInvoiceOrder::getDeductionRecordId,recordId);
+        return getOne(ew);
+    }
 }

+ 9 - 0
sp-server/src/main/java/com/pj/project/tb_refund_record/TbRefundRecordController.java

@@ -2,6 +2,7 @@ package com.pj.project.tb_refund_record;
 
 import java.util.List;
 
+import com.pj.constants.UserTypeEnum;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +32,10 @@ public class TbRefundRecordController {
 	@RequestMapping("getList")
 	public AjaxJson getList() { 
 		SoMap so = SoMap.getRequestSoMap();
+		String currentCustomerId = StpUserUtil.getCustomerId();
+		if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+			so.put("customerId", currentCustomerId);
+		}
 		List<TbRefundRecord> list = tbRefundRecordService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
@@ -38,6 +43,10 @@ public class TbRefundRecordController {
 	@SaCheckPermission(value = TbRefundRecord.PERMISSION_CODE_EXPORT)
 	public AjaxJson export() {
 		SoMap so = SoMap.getRequestSoMap();
+		String currentCustomerId = StpUserUtil.getCustomerId();
+		if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+			so.put("customerId", currentCustomerId);
+		}
 		String url = tbRefundRecordService.export(so);
 		return AjaxJson.getSuccessData(url);
 	}