Atitit. atiOrder Order 訂單管理框架的設計 1. Order 訂單處理流程1 2. code2 3. Ref7 1. Order 訂單處理流程 if(userSvr.isNotLogin()) { throw new RuntimeException(" not login 沒
Atitit. atiOrder Order 訂單管理框架的設計
1. Order 訂單處理流程
if(userSvr.isNotLogin())
{
throw new RuntimeException(" not login 沒登錄,請先登錄..#not_login");
}
User u=userSvr.getLoginUser();
Acc a=accSvr.getAcc(u.id);
BigDecimal needMoney=amoutCalcSvr.calc(order);
if(new ADecimal(needMoney ).biggerEqualThan(a.amount))
throw new RuntimeException(" amount not enough 金額不足夠 ..#amount_not_enough ");
///...insert
storeSvr.insert(order);
orderlogSvr.log(order);
return accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
作者:: 綽號:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊 ) 漢字名:艾龍, EMAIL:[email protected]
轉載請註明來源: http://www.cnblogs.com/attilax/
2. code
package com.attilax.order;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import aaaCfg.IocX4casher;
import com.attilax.acc.Acc;
import com.attilax.acc.AccService;
import com.attilax.bet.AmountCalcService;
import com.attilax.db.DBX;
import com.attilax.io.filex;
import com.attilax.json.AtiJson;
import com.attilax.math.ADecimal;
import com.attilax.orm.AOrm;
import com.attilax.store.StoreService;
import com.attilax.user.User;
import com.attilax.user.UserService;
import com.google.inject.Inject;
public class OrderServiceV2 extends absService {
public static void main(String[] args) {
//final long time_intFmt = new Date().getTime() / 1000;
//System.out.println(time_intFmt);
//OrderServiceV2 os = IocX4casher.getBean(OrderServiceV2.class);
//os.insert(new HashMap() {
//{
//this.put("good_amount", 12.50);
//this.put("add_time", time_intFmt);
//this.put("confirm_time", time_intFmt);
//this.put("order_sn",filex.getUUidName());
//}
//});
//System.out.println("--f");
}
@Inject
StoreService storeSvr;
@Inject
UserService userSvr;
@Inject
AccService accSvr;
@Inject
AmountCalcService amoutCalcSvr;
@Inject
OrderLogService orderlogSvr;
public int insert(Map order) {
if(userSvr.isNotLogin())
{
throw new RuntimeException(" not login 沒登錄,請先登錄..#not_login");
}
User u=userSvr.getLoginUser();
Acc a=accSvr.getAcc(u.id);
BigDecimal needMoney=amoutCalcSvr.calc(order);
if(new ADecimal(needMoney ).biggerEqualThan(a.amount))
throw new RuntimeException(" amount not enough 金額不足夠 ..#amount_not_enough ");
///...insert
storeSvr.insert(order);
orderlogSvr.log(order);
return accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
}
public List<Map> query(Map order) {
if(userSvr.isNotLogin())
{
throw new RuntimeException(" not login 沒登錄,請先登錄..#not_login");
}
User u=userSvr.getLoginUser();
return null;
///...insert
//return accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
}
public String query2json(Map order) {
return AtiJson.toJson(query(order));
///...insert
//return accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
}
}
3. Ref
Atitit. 訂單管理 收銀單持久化 功能設計 基於ecshop訂單結構