退款处理

This commit is contained in:
wangh 2024-01-16 16:10:28 +08:00
parent 4cddc769d1
commit 82a739ce75
14 changed files with 243 additions and 61 deletions

View File

@ -12,5 +12,8 @@ public class LJGoodsDto extends LJGoods {
// 变动原因
private String document;
private String oddNumber;
}

View File

@ -257,6 +257,7 @@ public class LJGoodsServiceImpl extends ServiceImpl<LJGoodsMapper, LJGoods> impl
stockTrack.setStoreId(goods.getStoreId());
stockTrack.setDocument(goods.getDocument());
stockTrack.setChangeNumber(goods.getNumberOfChanges());
stockTrack.setOddNumber(goods.getOddNumber());
int i = trackService.insertStockTrack(stockTrack);
return i>0;
}

View File

@ -71,4 +71,9 @@ public class AllOrderInfoController extends BaseController {
public ResponseObject refund(@RequestBody Map<String,String> map){
return getSuccessResult(allOrderInfoService.refund(map));
}
@GetMapping("/getOrderInfo")
public ResponseObject getOrderInfo(String orderNo, String type) {
return getSuccessResult(allOrderInfoService.getOrderInfo(orderNo,type));
}
}

View File

@ -60,4 +60,7 @@ public interface AllOrderInfoService {
public int getOrderNum(Integer StoreId);
Integer getOrderInfo(String orderNo, String type);
}

View File

@ -24,7 +24,9 @@ import com.fuint.business.order.mapper.AllOrderInfoMapper;
import com.fuint.business.order.service.*;
import com.fuint.business.order.vo.AllOrderInfoVo;
import com.fuint.business.order.vo.OrderGoodsVo;
import com.fuint.business.petrolStationManagement.entity.OilGun;
import com.fuint.business.petrolStationManagement.entity.OilTracking;
import com.fuint.business.petrolStationManagement.service.OilGunService;
import com.fuint.business.petrolStationManagement.service.OilTankService;
import com.fuint.business.petrolStationManagement.service.OilTrackingService;
import com.fuint.repository.mapper.MtOpenGiftMapper;
@ -32,6 +34,7 @@ import com.fuint.repository.model.MtOrderGoods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
@ -133,28 +136,29 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
@Resource
OilTrackingService oilTrackingService;
@Override
@Transactional
public int refund(Map<String, String> map) {
Map<String, String> refund = null;
Map<String, String> refund = new HashMap<>();
try {
AllOrderInfo allOrderInfo = selectAllOrderInfoByOrderNo(map.get("orderNo"));
if (ObjectUtil.isEmpty(map.get("type"))) {
throw new RuntimeException("该订单不支持退款,无退款类别!");
}else if ("oilOrder".equals(map.get("type")) || "goodsOrder".equals(map.get("type"))) {
}else if ("canRefund".equals(map.get("type"))) {
// 根据订单号查询订单
if ("APPLET_CODE".equals(allOrderInfo.getPayType())) { // 储值卡不支持退款
throw new RuntimeException("该订单不支持退款!");
}
// 判断是否有退款金额
if (ObjectUtil.isNotEmpty(allOrderInfo.getPayMoney()) && ObjectUtil.isNotEmpty(map.get("refundAmt"))) {
// 判断是否有退款金额 && ObjectUtil.isNotEmpty(map.get("refundAmt") // 目前全退
if (ObjectUtil.isNotEmpty(allOrderInfo.getPayMoney())) {
// 总金额金钱的传值需要×100
BigDecimal payMoneyBig = new BigDecimal(allOrderInfo.getPayMoney().toString());
BigDecimal payMoneyBefBig = payMoneyBig.multiply(new BigDecimal("100"));
// 退款金额(暂不支持部分退款)
// BigDecimal refundAmtBig = new BigDecimal(map.get("refundAmt"));
// BigDecimal refundAmtBefBig = refundAmtBig.multiply(new BigDecimal("100"));
map.put("totalAmt",payMoneyBefBig.toString());
map.put("refundAmt",payMoneyBefBig.toString());
map.put("totalAmt",payMoneyBefBig.stripTrailingZeros().toString());
map.put("refundAmt",payMoneyBefBig.stripTrailingZeros().toString());
map.put("orderNo",allOrderInfo.getOrderNo());
map.put("payType",allOrderInfo.getPayType());
@ -169,15 +173,20 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
throw new RuntimeException("该订单类型不支持退款!");
}
refund = fyPayService.refund(map);
if (!"CASH".equals(allOrderInfo.getPayType())) {
refund = fyPayService.refund(map);
}else {
// 现金退款处理
refund.put("result_msg","SUCCESS");
}
// 处理退款结果
if (ObjectUtil.isNotEmpty(refund.get("result_msg"))) {
if ("SUCCESS".equals(refund.get("result_msg"))) {
// 修改该总订单的数据
allOrderInfo.setPayType("refund");
// allOrderInfo.setReasonRefund("refund");
// allOrderInfo.setRefOrderNo("refund");
allOrderInfo.setStatus("refund");
allOrderInfo.setReasonRefund(map.get("refundRemark"));
allOrderInfo.setRefOrderNo(map.get("refundOrderNo"));
baseMapper.updateById(allOrderInfo);
// 处理油品订单
OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(map.get("orderNo"));
@ -190,19 +199,17 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
cashierOrderService.updateById(orderNo);
}
if (ObjectUtil.isNotEmpty(oilOrder)) {
disposeOil(oilOrder);
disposeOil(oilOrder,map.get("refundOrderNo"));
}
if (ObjectUtil.isNotEmpty(ljOrder)) {
disposeGoods(ljOrder);
disposeGoods(ljOrder,map.get("refundOrderNo"));
}
}else {
throw new RuntimeException("退款失败");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("退款失败");
}
log.info("refund{}",refund);
@ -224,8 +231,11 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
return map;
}
@Resource
OilGunService oilGunService;
// 处理油品
private void disposeOil(OilOrder oilOrder) {
private void disposeOil(OilOrder oilOrder,String refundOrderNo) {
// 处理订单状态
oilOrder.setOrderStatus("refund");
oilOrderService.updateById(oilOrder);
@ -234,23 +244,22 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
List<OilOrder> oilOrders = oilOrderService.selectOilOrder(oilOrder.getOrderNo());
// 获取油罐数据
for (OilOrder order : oilOrders) {
OilGun oilGun = oilGunService.queryById(Integer.valueOf(order.getOilGunNum()));
// 处理库存
oilTankService.addStoredQuantity(order.getTankId(),order.getOilNum());
oilTankService.addStoredQuantity(oilGun.getTankId(),order.getOilNum());
// 处理库存跟踪
OilTracking oilTracking = new OilTracking();
oilTracking.setDocument("油品退款");
oilTracking.setQuantityChange(-order.getOilNum());
oilTracking.setQuantityChange(order.getOilNum());
oilTracking.setStoreId(order.getStoreId());
oilTracking.setTankId(order.getTankId());
oilTracking.setTankId(oilGun.getTankId());
oilTracking.setOrderNumber(refundOrderNo);
OilTracking insert = oilTrackingService.insert(oilTracking);
}
/**
* todo
* 油品总价计算
*/
}
// 处理商品
private void disposeGoods(LJOrder ljOrder) {
private void disposeGoods(LJOrder ljOrder,String refundOrderNo) {
// 处理订单状态
ljOrder.setStatus("refund");
ljOrderService.updateById(ljOrder);
@ -261,11 +270,33 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
LJGoodsDto goods = new LJGoodsDto();
goods.setId(orderGoodsVo.getOrderId());
goods.setNumberOfChanges(ljOrder.getGoodsNum());
goods.setDocument("商品退款");
goods.setOddNumber(refundOrderNo);
ljGoodsService.editGoodsInventory(goods);
}
}
/**
* 查询退款提醒
*/
public Integer getOrderInfo(String orderNo, String type) {
// 处理油品订单
OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(orderNo);
// 处理商品订单
LJOrder ljOrder = ljOrderService.selectGoodsOrder(orderNo);
if ("oil".equals(type)) {
if (ObjectUtil.isNotEmpty(ljOrder)) {
return 1;
}
}else if ("goods".equals(type)) {
if (ObjectUtil.isNotEmpty(oilOrder)) {
return 1;
}
}
return 0;
}
}

View File

@ -86,7 +86,7 @@ public interface OilTankMapper {
* @return 影响行数
*/
int update(OilTank oilTank);
int addStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum,Double totalAmount,Double discountedPrice);
int addStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum,@Param("totalAmount") Double totalAmount, @Param("discountedPrice")Double discountedPrice);
int subtractStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum);

View File

@ -429,7 +429,7 @@
total_price = total_price + #{totalAmount},
</if>
<if test="discountedPrice != null and discountedPrice != ''">
discounted_price = #{discountedPrice}
discounted_price = #{discountedPrice},
</if>
update_time = NOW()
where id = #{tankId}

View File

@ -196,7 +196,7 @@ public class OilTankServiceImpl implements OilTankService {
// 单价*油量
BigDecimal disPrice = new BigDecimal(oilTank.getDiscountedPrice().toString());
BigDecimal multiply = disPrice.multiply(new BigDecimal(changeNum));
return this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, multiply.doubleValue(),null) >0 ;
return this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, Double.valueOf(multiply.toString()),null) >0 ;
}
/**

View File

@ -8,3 +8,10 @@ export function refundApi(data) {
data: data
})
}
export function getOrderInfoApi(data) {
return request({
url: '/business/allOrderInfo/getOrderInfo',
method: 'get',
params: data
})
}

View File

@ -110,8 +110,9 @@
<el-table-column prop="payUser" label="付款用户"> </el-table-column>
<el-table-column prop="status" label="状态">
<template slot-scope="scope">
<el-tag v-if="scope.row.status == 'unpaid'">未支付</el-tag>
<el-tag type="success" v-else-if="scope.row.status == 'paid'">已支付</el-tag>
<el-tag v-if="scope.row.status === 'unpaid'">未支付</el-tag>
<el-tag type="success" v-else-if="scope.row.status === 'paid'">已支付</el-tag>
<el-tag type="danger" v-else-if="scope.row.status === 'refund'">已退款</el-tag>
<el-tag type="danger" v-else>支付失败</el-tag>
</template>
</el-table-column>
@ -129,6 +130,7 @@
@click="patchwork(scope.row)"
type="primary" plain round>补打</el-button>
<el-button style="width: 60px" size="mini"
v-if = "scope.row.status !== 'refund'"
@click="handleRefund(scope.row.id)"
type="danger" plain round>退款</el-button>
</template>
@ -356,23 +358,48 @@ import {refundApi} from "@/api/cashier/refund";
},
// 退
handleRefund(id){
this.dialogRefund = true;
cashierOrder(id).then( response => {
this.cashierOrder = response.data
})
//退
this.$confirm('是否将该收银台下的订单全部退款, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.dialogRefund = true;
cashierOrder(id).then( response => {
this.cashierOrder = response.data
if (response.data.status === "refund") {
this.$message({
type: 'info',
message: '该订单已经退款'
});
this.dialogRefund = false;
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
refundConfirmed() {
this.dialogRefund = false;
// 退
// cashierOrder
console.log("cashierOrder",this.cashierOrder)
let map={
orderNo: this.cashierOrder.orderNo,
storeId: this.cashierOrder.storeId,
type: "cashierOrder"
refundRemark:this.radio1 +"-"+ this.refundRemark,
type: "canRefund"
}
refundApi(map).then(res=>{
this.$message({
type: 'info',
message: '退款成功'
});
this.getList();
this.getOrderStatistics();
this.getStaffList();
})
},

View File

@ -140,6 +140,7 @@
<template slot-scope="scope">
<el-tag v-if="scope.row.status == 'unpaid'">未支付</el-tag>
<el-tag type="success" v-else-if="scope.row.status == 'paid'">已支付</el-tag>
<el-tag type="danger" v-else-if="scope.row.status === 'refund'">已退款</el-tag>
<el-tag type="danger" v-else>支付失败</el-tag>
</template>
</el-table-column>
@ -154,17 +155,14 @@
<span>{{ parseTime(scope.row.payTime) }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!-- <template slot-scope="scope">-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- >更多操作</el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button style="width: 60px" size="mini"
v-if = "scope.row.status !== 'refund'"
@click="handleRefund(scope.row.id)"
type="danger" plain round>退款</el-button>
</template>
</el-table-column>
</el-table>
</div>
@ -225,10 +223,12 @@
</template>
<script>
import {getOrderGoods, listOrder,orderStatisticsApi} from "@/api/cashier/goodsorder";
import {getGoodsOrder, getOrderGoods, listOrder, orderStatisticsApi} from "@/api/cashier/goodsorder";
import {queryStaffs} from "@/api/cashier/staff";
import {getDicts} from "@/api/dict/data";
import { exportExcelGoodsOrderApi } from "@/api/order/exportExcel";
import {cashierOrder} from "@/api/cashier/cashierorder";
import {refundApi, getOrderInfoApi} from "@/api/cashier/refund";
export default {
name: "order_Cashier",
@ -262,6 +262,7 @@ export default {
page: 1,
pageSize: 10,
},
orderGoods:'',
//
payList:[],
dialogRefund: false,
@ -299,6 +300,65 @@ export default {
this.orderStatistics = res.data;
})
},
// 退
async handleRefund(id){
let title = '是否将该收银台下的订单全部退款'
await getOrderInfoApi().then(res=>{
if (res.code === 200) {
if (res.data === 1) {
title = '该订单下有其它油品订单,是否一并退款'
}
}
});
this.$confirm(title+', 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.dialogRefund = true;
getGoodsOrder({"id":id}).then( response => {
this.goods = response.data
if (response.data.status === "refund") {
this.$message({
type: 'info',
message: '该订单已经退款'
});
this.dialogRefund = false;
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
this.dialogRefund = false;
});
},
// 退
refundConfirmed() {
this.dialogRefund = false;
console.log("cashierOrder",this.goods)
let map={
orderNo: this.goods.orderNo,
storeId: this.goods.storeId,
refundRemark:this.radio1 +"-"+ this.refundRemark,
type: "canRefund"
}
refundApi(map).then(res=>{
if (res.code === 200){
this.$message({
type: 'info',
message: '退款成功'
});
this.created()
}
})
},
// id
queryStaf(list,id){
let name = "";

View File

@ -187,8 +187,9 @@
</el-table-column>
<el-table-column prop="orderStatus" label="付款状态" align="center" width="120">
<template slot-scope="scope">
<el-tag v-if="scope.row.orderStatus == 'unpaid'">未支付</el-tag>
<el-tag type="success" v-else-if="scope.row.orderStatus == 'paid'">已支付</el-tag>
<el-tag v-if="scope.row.orderStatus === 'unpaid'">未支付</el-tag>
<el-tag type="success" v-else-if="scope.row.orderStatus === 'paid'">已支付</el-tag>
<el-tag type="danger" v-else-if="scope.row.orderStatus === 'refund'">已退款</el-tag>
<el-tag type="danger" v-else>支付失败</el-tag>
</template>
</el-table-column>
@ -208,6 +209,7 @@
type="primary" plain round>补打</el-button>
<el-button style="width: 60px" size="mini"
@click="handleRefund(scope.row.id)"
v-if = "scope.row.status !== 'refund'"
type="danger" plain round>退款</el-button>
</template>
</el-table-column>
@ -251,7 +253,7 @@
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogRefund = false"> </el-button>
<el-button type="primary" @click="dialogRefund = false"> </el-button>
<el-button type="primary" @click="refundConfirmed()"> </el-button>
</span>
</el-dialog>
</div>
@ -265,6 +267,8 @@
import {getUser, queryUsers} from "@/api/cashier/user/user";
import {oilNumberList, oilNumbers} from "@/api/cashier/oilnumber";
import {getOilGuns, getOilNumberGun} from "@/api/cashier/oilGuns";
import {cashierOrder} from "@/api/cashier/cashierorder";
import {getOrderInfoApi, refundApi} from "@/api/cashier/refund";
export default {
name: "order_Cashier",
@ -363,10 +367,51 @@
}).catch(() => {});
},
// 退
handleRefund(id){
this.dialogRefund = true;
oilOrderInfo(id).then( response => {
this.oilOrder = response.data
async handleRefund(id){
let title = '是否将该收银台下的订单全部退款'
await getOrderInfoApi().then(res=>{
if (res.code === 200) {
if (res.data === 1) {
title = '该订单下有其它商品订单,是否一并退款'
}
}
});
//退
this.$confirm(title+', 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.dialogRefund = true;
oilOrderInfo(id).then( response => {
this.oilOrder = response.data
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
refundConfirmed() {
this.dialogRefund = false;
console.log("cashierOrder",this.cashierOrder)
let map={
orderNo: this.oilOrder.orderNo,
storeId: this.oilOrder.storeId,
refundRemark:this.radio1 +"-"+ this.refundRemark,
type: "canRefund"
}
refundApi(map).then(res=>{
this.$message({
type: 'info',
message: '退款成功'
});
this.created()
})
},
// id

View File

@ -152,9 +152,9 @@
<el-button style="width: 60px" size="mini"
@click="patchwork(scope.row)"
type="primary" plain round>补打</el-button>
<el-button style="width: 60px" size="mini"
@click="handleRefund(scope.row.id)"
type="danger" plain round>退款</el-button>
<!-- <el-button style="width: 60px" size="mini"-->
<!-- @click="handleRefund(scope.row.id)"-->
<!-- type="danger" plain round>退款</el-button>-->
</template>
</el-table-column>

View File

@ -167,9 +167,9 @@
<el-button style="width: 60px" size="mini"
@click="patchwork(scope.row)"
type="primary" plain round>补打</el-button>
<el-button style="width: 60px" size="mini"
@click="handleRefund(scope.row.id)"
type="danger" plain round>退款</el-button>
<!-- <el-button style="width: 60px" size="mini"-->
<!-- @click="handleRefund(scope.row.id)"-->
<!-- type="danger" plain round>退款</el-button>-->
</template>
</el-table-column>