Authored by mali

Merge branch 'dev_bills'

1 package com.yoho.ufo.order.controller; 1 package com.yoho.ufo.order.controller;
2 2
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.core.rest.client.ServiceCaller;
3 import com.yoho.order.model.TradeBillsReq; 5 import com.yoho.order.model.TradeBillsReq;
4 import com.yoho.ufo.order.service.ITradeBillsService; 6 import com.yoho.ufo.order.service.ITradeBillsService;
  7 +import com.yoho.ufo.service.impl.UserHelper;
5 import com.yoho.ufo.service.model.ApiResponse; 8 import com.yoho.ufo.service.model.ApiResponse;
6 import com.yoho.ufo.service.model.PageResponseBO; 9 import com.yoho.ufo.service.model.PageResponseBO;
7 -import com.yohobuy.ufo.model.order.resp.*; 10 +import com.yohobuy.ufo.model.order.req.ManualDealRequest;
  11 +import com.yohobuy.ufo.model.order.resp.TradeBillsResp;
  12 +import org.apache.commons.lang3.StringUtils;
8 import org.slf4j.Logger; 13 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory; 14 import org.slf4j.LoggerFactory;
10 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +25,9 @@ public class TradeBillsController { @@ -20,6 +25,9 @@ public class TradeBillsController {
20 @Autowired 25 @Autowired
21 private ITradeBillsService billsTradeService; 26 private ITradeBillsService billsTradeService;
22 27
  28 + @Autowired
  29 + private ServiceCaller serviceCaller;
  30 +
23 @RequestMapping(value = "/queryTradeBillsList") 31 @RequestMapping(value = "/queryTradeBillsList")
24 public ApiResponse queryTradeBillsList(TradeBillsReq req) { 32 public ApiResponse queryTradeBillsList(TradeBillsReq req) {
25 LOGGER.info("queryBillsTradeList in. req is {}", req); 33 LOGGER.info("queryBillsTradeList in. req is {}", req);
@@ -27,4 +35,35 @@ public class TradeBillsController { @@ -27,4 +35,35 @@ public class TradeBillsController {
27 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); 35 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
28 } 36 }
29 37
  38 + /**
  39 + * 人工退款
  40 + * @param req
  41 + * @return
  42 + */
  43 + @RequestMapping(value = "/manualRefund")
  44 + public ApiResponse manualRefund(ManualDealRequest req) {
  45 + LOGGER.info("TradeBillsController manualRefund in. req is {}", req);
  46 + if(req.getTradeBillsId()==null||req.getUid()<=0||req.getOrderCode()<=0){
  47 + return new ApiResponse.ApiResponseBuilder().code(201).message("参数不合法").data(null).build();
  48 + }
  49 +
  50 + if(req.getAlipayAccount()==null|| StringUtils.isBlank(req.getAlipayAccount())){
  51 + return new ApiResponse.ApiResponseBuilder().code(201).message("参数不合法:支付宝账号为空").data(null).build();
  52 + }
  53 +
  54 + UserHelper userHelper=new UserHelper();
  55 + req.setOperateUid(userHelper.getUserId());
  56 + req.setOperateUname(userHelper.getUserName());
  57 +
  58 + ApiResponse apiResponse=new ApiResponse();
  59 + JSONObject jsonObject = serviceCaller.asyncCall("ufo-gateway.manualDealMon", req, JSONObject.class).get(5);
  60 + LOGGER.info("call ufo-gateway.manualDealMon interface is {}, result is {}", jsonObject.toJSONString());
  61 + int resultCode=jsonObject.getIntValue("code");
  62 + if(200!=resultCode){
  63 + apiResponse.setCode(resultCode);
  64 + apiResponse.setMessage(jsonObject.getString("message"));
  65 + }
  66 + return apiResponse;
  67 + }
  68 +
30 } 69 }
@@ -38,6 +38,30 @@ @@ -38,6 +38,30 @@
38 <div id="tradeBillsList" region="center"> 38 <div id="tradeBillsList" region="center">
39 <table id="tradeBillsListTable"></table> 39 <table id="tradeBillsListTable"></table>
40 </div> 40 </div>
  41 +
  42 +<div id="refundConfirmDialog" class="easyui-dialog" style="width:400px;height:300px;"
  43 + data-options="title:'人工打款确认',buttons:'#refundConfirmDialog_tb',modal:true,closed:true">
  44 + <div style="padding:20px;">
  45 + <input id="refund_tradeBillsId" type="hidden" readonly disabled/>
  46 + <input id="refund_uid" type="hidden" readonly disabled/>
  47 + <label>订 单 编 号:</label>
  48 + <input id="refund_orderCode" type="text" class="easyui-textbox" style="width:250px" readonly disabled/>
  49 +
  50 + <br/><br/>
  51 + <label>支付宝账号:</label>
  52 + <input id="refund_alipayAccount" type="text" class="easyui-textbox" style="width:250px" readonly disabled/>
  53 +
  54 + <br/><br/>
  55 + <label>打 款 金 额:</label>
  56 + <input id="refund_amount" type="text" class="easyui-textbox" style="width:250px" readonly disabled/>
  57 +
  58 + </div>
  59 +</div>
  60 +<div id="refundConfirmDialog_tb">
  61 + <a href="#" id="refundConfirmDialog_btn_save" onclick="refundGo();" class="easyui-linkbutton btn-danger" >确定</a>
  62 + <a href="#" id="refundConfirmDialog_btn_close" onclick="$('#refundConfirmDialog').dialog('close');" class="easyui-linkbutton btn-info" >关闭</a>
  63 +</div>
  64 +
41 <script> 65 <script>
42 $(function() { 66 $(function() {
43 $("#status").combobox({ 67 $("#status").combobox({
@@ -56,30 +80,21 @@ $(function() { @@ -56,30 +80,21 @@ $(function() {
56 return; 80 return;
57 }*/ 81 }*/
58 82
  83 + loadTradeBillsData();
  84 + }
  85 + });
  86 +
  87 + getTradeBillsList();
  88 +});
  89 +
  90 +function loadTradeBillsData() {
59 $("#tradeBillsListTable").datagrid("load", { 91 $("#tradeBillsListTable").datagrid("load", {
60 status : $("#status").myCombobox("getValue"), 92 status : $("#status").myCombobox("getValue"),
61 orderCode : $("#orderCode").val(), 93 orderCode : $("#orderCode").val(),
62 uid : $("#uid").val(), 94 uid : $("#uid").val(),
63 mobile : $("#mobile").val() 95 mobile : $("#mobile").val()
64 }); 96 });
65 - }  
66 - });  
67 -  
68 - //全部按钮  
69 - /* $("#allBtn").linkbutton({  
70 - iconCls: "icon-import",  
71 - onClick: function () {  
72 - $("#orderCode").textbox('setValue','');  
73 - $("#status").combobox('setValue','');  
74 - //$("#uid").textbox('setValue','');  
75 - $("#mobile").textbox('setValue','');  
76 - $("#orderListTable").datagrid("load", {  
77 - });  
78 - }  
79 - });*/  
80 -  
81 - getTradeBillsList();  
82 -}); 97 +}
83 98
84 function getTradeBillsList(){ 99 function getTradeBillsList(){
85 $("#tradeBillsListTable").myDatagrid({ 100 $("#tradeBillsListTable").myDatagrid({
@@ -150,7 +165,13 @@ function getTradeBillsList(){ @@ -150,7 +165,13 @@ function getTradeBillsList(){
150 align: "center", 165 align: "center",
151 formatter: function (value, rowData, rowIndex) { 166 formatter: function (value, rowData, rowIndex) {
152 if (rowData.tradeStatus != 100) { 167 if (rowData.tradeStatus != 100) {
153 - return "<a role='refundsConfirm' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #5cb85c !important;'>打款</a>"; 168 + var btn= "<a role='refundsConfirm' onclick='openConfirmDialog(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\")' style='margin-left:10px;background-color: #5cb85c !important;'>打款</a>";
  169 + btn = btn.replace("%s",rowData.id);
  170 + btn = btn.replace("%s",rowData.uid);
  171 + btn = btn.replace("%s",rowData.orderCode);
  172 + btn = btn.replace("%s",rowData.alipayAccount);
  173 + btn = btn.replace("%s",rowData.amount);
  174 + return btn;
154 } 175 }
155 } 176 }
156 }]], 177 }]],
@@ -160,14 +181,55 @@ function getTradeBillsList(){ @@ -160,14 +181,55 @@ function getTradeBillsList(){
160 idField: "id", 181 idField: "id",
161 singleSelect: true, 182 singleSelect: true,
162 onLoadSuccess: function (data) { 183 onLoadSuccess: function (data) {
163 - $(this).datagrid("getPanel").find("a[role='refundsConfirm']").linkbutton({  
164 - onClick: function () {  
165 - var id = $(this).attr("dataId");  
166 - alert("开发中。。"); 184 + $(this).datagrid("getPanel").find("a[role='refundsConfirm']").linkbutton({});
167 } 185 }
168 }); 186 });
  187 +}
  188 +
  189 +function openConfirmDialog(id,uid,orderCode,alipayAccount,amount) {
  190 + //重新赋值
  191 + $("#refund_tradeBillsId").val(id);
  192 + $("#refund_uid").val(uid);
  193 + $("#refund_orderCode").textbox('setValue',orderCode);
  194 + $("#refund_alipayAccount").textbox('setValue',alipayAccount);
  195 + $("#refund_amount").textbox('setValue',amount);
  196 +
  197 + $("#refundConfirmDialog").dialog('open');
  198 +}
  199 +
  200 +//确认打款
  201 +function refundGo() {
  202 + var param={};
  203 + param.tradeBillsId = $("#refund_tradeBillsId").val();
  204 + param.uid=$("#refund_uid").val();
  205 + param.orderCode=$("#refund_orderCode").val();
  206 + param.alipayAccount=$("#refund_alipayAccount").val();
  207 + param.amount=$("#refund_amount").val();
  208 +
  209 + //发送请求
  210 + $.ajax({
  211 + type: "POST",
  212 + url: contextPath + '/tradeBills/manualRefund',
  213 + data: param,
  214 + async: false,
  215 + cache: false,
  216 + dataType: 'json',
  217 + success: function (result) {
  218 + if(result.code == 200) {
  219 + $("#refundConfirmDialog").dialog('close');
  220 + loadTradeBillsData();
  221 + }
  222 + else {
  223 + $.messager.alert("失败", result.message, "error");
  224 + $("#refundConfirmDialog").dialog('close');
  225 + loadTradeBillsData();
  226 + }
169 } 227 }
170 }); 228 });
  229 +
  230 + //按钮置灰
  231 + $("#refundConfirmDialog_btn_save").linkbutton("disabled");
  232 + $("#refundConfirmDialog_btn_close").linkbutton("disabled");
171 } 233 }
172 234
173 </script> 235 </script>