Authored by mali

Merge branch 'dev_bills'

package com.yoho.ufo.order.controller;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.order.model.TradeBillsReq;
import com.yoho.ufo.order.service.ITradeBillsService;
import com.yoho.ufo.service.impl.UserHelper;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.order.req.ManualDealRequest;
import com.yohobuy.ufo.model.order.resp.TradeBillsResp;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -20,6 +25,9 @@ public class TradeBillsController {
@Autowired
private ITradeBillsService billsTradeService;
@Autowired
private ServiceCaller serviceCaller;
@RequestMapping(value = "/queryTradeBillsList")
public ApiResponse queryTradeBillsList(TradeBillsReq req) {
LOGGER.info("queryBillsTradeList in. req is {}", req);
... ... @@ -27,4 +35,35 @@ public class TradeBillsController {
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
/**
* 人工退款
* @param req
* @return
*/
@RequestMapping(value = "/manualRefund")
public ApiResponse manualRefund(ManualDealRequest req) {
LOGGER.info("TradeBillsController manualRefund in. req is {}", req);
if(req.getTradeBillsId()==null||req.getUid()<=0||req.getOrderCode()<=0){
return new ApiResponse.ApiResponseBuilder().code(201).message("参数不合法").data(null).build();
}
if(req.getAlipayAccount()==null|| StringUtils.isBlank(req.getAlipayAccount())){
return new ApiResponse.ApiResponseBuilder().code(201).message("参数不合法:支付宝账号为空").data(null).build();
}
UserHelper userHelper=new UserHelper();
req.setOperateUid(userHelper.getUserId());
req.setOperateUname(userHelper.getUserName());
ApiResponse apiResponse=new ApiResponse();
JSONObject jsonObject = serviceCaller.asyncCall("ufo-gateway.manualDealMon", req, JSONObject.class).get(5);
LOGGER.info("call ufo-gateway.manualDealMon interface is {}, result is {}", jsonObject.toJSONString());
int resultCode=jsonObject.getIntValue("code");
if(200!=resultCode){
apiResponse.setCode(resultCode);
apiResponse.setMessage(jsonObject.getString("message"));
}
return apiResponse;
}
}
... ...
... ... @@ -38,6 +38,30 @@
<div id="tradeBillsList" region="center">
<table id="tradeBillsListTable"></table>
</div>
<div id="refundConfirmDialog" class="easyui-dialog" style="width:400px;height:300px;"
data-options="title:'人工打款确认',buttons:'#refundConfirmDialog_tb',modal:true,closed:true">
<div style="padding:20px;">
<input id="refund_tradeBillsId" type="hidden" readonly disabled/>
<input id="refund_uid" type="hidden" readonly disabled/>
<label>订 单 编 号:</label>
<input id="refund_orderCode" type="text" class="easyui-textbox" style="width:250px" readonly disabled/>
<br/><br/>
<label>支付宝账号:</label>
<input id="refund_alipayAccount" type="text" class="easyui-textbox" style="width:250px" readonly disabled/>
<br/><br/>
<label>打 款 金 额:</label>
<input id="refund_amount" type="text" class="easyui-textbox" style="width:250px" readonly disabled/>
</div>
</div>
<div id="refundConfirmDialog_tb">
<a href="#" id="refundConfirmDialog_btn_save" onclick="refundGo();" class="easyui-linkbutton btn-danger" >确定</a>
<a href="#" id="refundConfirmDialog_btn_close" onclick="$('#refundConfirmDialog').dialog('close');" class="easyui-linkbutton btn-info" >关闭</a>
</div>
<script>
$(function() {
$("#status").combobox({
... ... @@ -56,30 +80,21 @@ $(function() {
return;
}*/
loadTradeBillsData();
}
});
getTradeBillsList();
});
function loadTradeBillsData() {
$("#tradeBillsListTable").datagrid("load", {
status : $("#status").myCombobox("getValue"),
orderCode : $("#orderCode").val(),
uid : $("#uid").val(),
mobile : $("#mobile").val()
});
}
});
//全部按钮
/* $("#allBtn").linkbutton({
iconCls: "icon-import",
onClick: function () {
$("#orderCode").textbox('setValue','');
$("#status").combobox('setValue','');
//$("#uid").textbox('setValue','');
$("#mobile").textbox('setValue','');
$("#orderListTable").datagrid("load", {
});
}
});*/
getTradeBillsList();
});
}
function getTradeBillsList(){
$("#tradeBillsListTable").myDatagrid({
... ... @@ -150,7 +165,13 @@ function getTradeBillsList(){
align: "center",
formatter: function (value, rowData, rowIndex) {
if (rowData.tradeStatus != 100) {
return "<a role='refundsConfirm' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #5cb85c !important;'>打款</a>";
var btn= "<a role='refundsConfirm' onclick='openConfirmDialog(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\")' style='margin-left:10px;background-color: #5cb85c !important;'>打款</a>";
btn = btn.replace("%s",rowData.id);
btn = btn.replace("%s",rowData.uid);
btn = btn.replace("%s",rowData.orderCode);
btn = btn.replace("%s",rowData.alipayAccount);
btn = btn.replace("%s",rowData.amount);
return btn;
}
}
}]],
... ... @@ -160,14 +181,55 @@ function getTradeBillsList(){
idField: "id",
singleSelect: true,
onLoadSuccess: function (data) {
$(this).datagrid("getPanel").find("a[role='refundsConfirm']").linkbutton({
onClick: function () {
var id = $(this).attr("dataId");
alert("开发中。。");
$(this).datagrid("getPanel").find("a[role='refundsConfirm']").linkbutton({});
}
});
}
function openConfirmDialog(id,uid,orderCode,alipayAccount,amount) {
//重新赋值
$("#refund_tradeBillsId").val(id);
$("#refund_uid").val(uid);
$("#refund_orderCode").textbox('setValue',orderCode);
$("#refund_alipayAccount").textbox('setValue',alipayAccount);
$("#refund_amount").textbox('setValue',amount);
$("#refundConfirmDialog").dialog('open');
}
//确认打款
function refundGo() {
var param={};
param.tradeBillsId = $("#refund_tradeBillsId").val();
param.uid=$("#refund_uid").val();
param.orderCode=$("#refund_orderCode").val();
param.alipayAccount=$("#refund_alipayAccount").val();
param.amount=$("#refund_amount").val();
//发送请求
$.ajax({
type: "POST",
url: contextPath + '/tradeBills/manualRefund',
data: param,
async: false,
cache: false,
dataType: 'json',
success: function (result) {
if(result.code == 200) {
$("#refundConfirmDialog").dialog('close');
loadTradeBillsData();
}
else {
$.messager.alert("失败", result.message, "error");
$("#refundConfirmDialog").dialog('close');
loadTradeBillsData();
}
}
});
//按钮置灰
$("#refundConfirmDialog_btn_save").linkbutton("disabled");
$("#refundConfirmDialog_btn_close").linkbutton("disabled");
}
</script>
... ...