123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- <?php
- /**
- * Order.php UTF-8
- * 订单信息
- *
- * @date : 2018/1/19 14:59
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\controller\request;
- use think\Log;
- use think\Session;
- class Order {
- private $order_id = '';
- private $app_id = 0;
- private $status = 1;
- private $is_standard = 2;
- private $currency = 'CNY';
- private $cp_order_id = '';
- private $product_price = 0.00;
- private $product_real_price = 0.00;
- private $product_id = '';
- private $product_cnt = 1;
- private $product_name = '';
- private $product_desc = '';
- private $ext = ''; /* CP附加参数 */
- private $cp_payback_url = ''; /* CP回调地址 */
- private $coupon_amount = 0; /* 代金卷抵扣 */
- private $ptb_amount = 0; /* 平台币使用金额 */
- private $gm_amount = 0; /* 游戏币使用金额 */
- private $integral = 0; /* 游戏币使用金额 */
- private $integral_money = 0; /* 使用积分抵扣金额 */
- private $rebate_amount = 0; /* 返利金额 */
- private $payway = ''; /* 支付方式 */
- private $pay_time = 0; /* 支付完成时间 */
- private $is_distribute = ''; /* 是否已发货 */
- public function __construct($data = []) {
- if (!empty($data)) {
- $this->setData($data);
- }
- }
- /**
- * 设置订单数据
- *
- * @param array $data
- */
- public function setData($data = []) {
- if (empty($data)) {
- return;
- }
- $this->setOrderId(get_val($data, 'order_id'));
- $this->setIsStandard(get_val($data, 'is_standard', 2));
- $this->setCurrency(get_val($data, 'currency', 'CNY'));
- $this->setCpOrderId(get_val($data, 'cp_order_id'));
- $this->setProductPrice(get_val($data, 'product_price', 0.00));
- $this->setProductRealPrice(get_val($data, 'product_price', 0.00));
- $this->setProductId(get_val($data, 'product_id'));
- $this->setProductCnt(get_val($data, 'product_cnt', 1));
- $this->setProductName(get_val($data, 'product_name'));
- $this->setProductDesc(get_val($data, 'product_desc'));
- $this->setExt(get_val($data, 'ext'));
- }
- /**
- * 从查询中设置订单数据
- *
- * @param array $order_data
- */
- public function setDataFromOrder($order_data = []) {
- if (empty($order_data)) {
- return;
- }
- $this->setOrderId($order_data['order_id']);
- $this->setAppId($order_data['app_id']);
- $this->setCpOrderId($order_data['cp_order_id']);
- $this->setCurrency($order_data['currency']);
- $this->setProductPrice($order_data['amount']);
- $this->setProductRealPrice($order_data['real_amount']);
- $this->setProductId($order_data['product_id']);
- $this->setProductCnt($order_data['product_cnt']);
- $this->setProductName($order_data['product_name']);
- $this->setProductDesc($order_data['payext']['product_desc']);
- $this->setCouponAmount($order_data['coupon_amount']);
- $this->setPtbAmount($order_data['ptb_amount']);
- $this->setGmAmount($order_data['gm_amount']);
- $this->setIntegral($order_data['integral']);
- $this->setIntegralMoney($order_data['integral_money']);
- $this->setRebateAmount($order_data['rebate_amount']);
- $this->setPayway($order_data['payway']);
- $this->setStatus($order_data['status']);
- $this->setPayTime($order_data['pay_time']);
- }
- /**
- * @return string
- */
- public function getOrderId() {
- return $this->order_id;
- }
- /**
- * @param string $order_id
- */
- public function setOrderId($order_id) {
- $this->order_id = $order_id;
- }
- /**
- * @return int
- */
- public function getIsStandard() {
- return $this->is_standard;
- }
- /**
- * @param int $is_standard
- */
- public function setIsStandard($is_standard) {
- $this->is_standard = $is_standard;
- }
- /**
- * @return string
- */
- public function getCurrency() {
- return $this->currency;
- }
- /**
- * @param string $currency
- */
- public function setCurrency($currency) {
- $this->currency = $currency;
- }
- /**
- * @return string
- */
- public function getCpOrderId() {
- return $this->cp_order_id;
- }
- /**
- * @param string $cp_order_id
- */
- public function setCpOrderId($cp_order_id) {
- $this->cp_order_id = $cp_order_id;
- }
- /**
- * @return float
- */
- public function getProductPrice() {
- return $this->product_price;
- }
- /**
- * @param float $product_price
- */
- public function setProductPrice($product_price) {
- $this->product_price = $product_price;
- }
- /**
- * @return string
- */
- public function getProductId() {
- return $this->product_id;
- }
- /**
- * @param string $product_id
- */
- public function setProductId($product_id) {
- $this->product_id = $product_id;
- }
- /**
- * @return int
- */
- public function getProductCnt() {
- return $this->product_cnt;
- }
- /**
- * @param int $product_cnt
- */
- public function setProductCnt($product_cnt) {
- $this->product_cnt = $product_cnt;
- }
- /**
- * @return string
- */
- public function getProductName() {
- return $this->product_name;
- }
- /**
- * @param string $product_name
- */
- public function setProductName($product_name) {
- $this->product_name = $product_name;
- }
- /**
- * @return string
- */
- public function getProductDesc() {
- return $this->product_desc;
- }
- /**
- * @param string $product_desc
- */
- public function setProductDesc($product_desc) {
- $this->product_desc = $product_desc;
- }
- /**
- * @return string
- */
- public function getExt() {
- return $this->ext;
- }
- /**
- * @param string $ext
- */
- public function setExt($ext) {
- $this->ext = $ext;
- }
- /**
- * @return float
- */
- public function getProductRealPrice() {
- return $this->product_real_price;
- }
- /**
- * @param float $product_real_price
- */
- public function setProductRealPrice($product_real_price) {
- $this->product_real_price = $product_real_price;
- }
- /**
- * @return string
- */
- public function getCpPaybackUrl() {
- return $this->cp_payback_url;
- }
- /**
- * @param string $cp_payback_url
- */
- public function setCpPaybackUrl($cp_payback_url) {
- $this->cp_payback_url = $cp_payback_url;
- }
- /**
- * @param $order_id
- *
- * @return string
- */
- public function genPayToken($order_id) {
- $_pay_token = md5(md5($order_id).time());
- Session::set('pay_token', $_pay_token);
- return $_pay_token;
- }
- /**
- * @param string $pay_token
- *
- * @return bool
- */
- public function checkPayToken($pay_token) {
- $_check_pay_token = Session::get('pay_token');
- if (empty($_check_pay_token) || 0 != strcmp($_check_pay_token, $pay_token)) {
- return false;
- }
- Session::delete('pay_token');
- return true;
- }
- /**
- * @return int
- */
- public function getCouponAmount() {
- return $this->coupon_amount;
- }
- /**
- * @param int $coupon_amount
- */
- public function setCouponAmount($coupon_amount) {
- $this->coupon_amount = $coupon_amount;
- }
- /**
- * @return int
- */
- public function getPtbAmount() {
- return $this->ptb_amount;
- }
- /**
- * @param int $ptb_amount
- */
- public function setPtbAmount($ptb_amount) {
- $this->ptb_amount = $ptb_amount;
- }
- /**
- * @return int
- */
- public function getGmAmount() {
- return $this->gm_amount;
- }
- /**
- * @param int $gm_amount
- */
- public function setGmAmount($gm_amount) {
- $this->gm_amount = $gm_amount;
- }
- /**
- * @return int
- */
- public function getIntegral() {
- return $this->integral;
- }
- /**
- * @param int $integral
- */
- public function setIntegral($integral) {
- $this->integral = $integral;
- }
- /**
- * @return int
- */
- public function getIntegralMoney() {
- return $this->integral_money;
- }
- /**
- * @param int $integral_money
- */
- public function setIntegralMoney($integral_money) {
- $this->integral_money = $integral_money;
- }
- /**
- * @return int
- */
- public function getRebateAmount() {
- return $this->rebate_amount;
- }
- /**
- * @param int $rebate_amount
- */
- public function setRebateAmount($rebate_amount) {
- $this->rebate_amount = $rebate_amount;
- }
- /**
- * @return string
- */
- public function getPayway() {
- return $this->payway;
- }
- /**
- * @param string $payway
- */
- public function setPayway($payway) {
- $this->payway = $payway;
- }
- /**
- * @return string
- */
- public function getPayTime() {
- return $this->pay_time;
- }
- /**
- * @param string $pay_time
- */
- public function setPayTime($pay_time) {
- $this->pay_time = $pay_time;
- }
- /**
- * @return string
- */
- public function getIsDistribute() {
- return $this->is_distribute;
- }
- /**
- * @param string $is_distribute
- */
- public function setIsDistribute($is_distribute) {
- $this->is_distribute = $is_distribute;
- }
- public function toArray() {
- // TODO: wuyonghong 2018/4/27
- $_data = [
- 'order_id' => $this->getOrderId(),
- 'cp_order_id' => $this->getCpOrderId(),
- 'is_standard' => $this->getIsStandard(),
- 'currency' => $this->getCurrency(),
- 'amount' => $this->getProductPrice(),
- 'real_amount' => $this->getProductRealPrice(),
- 'product_id' => $this->getProductId(),
- 'product_cnt' => $this->getProductCnt(),
- 'product_name' => $this->getProductName(),
- 'product_desc' => $this->getProductPrice(),
- 'ext' => $this->getExt(),
- 'cp_payback_url' => $this->getCpPaybackUrl(),
- 'coupon_amount' => $this->getCouponAmount(),
- 'ptb_amount' => $this->getPtbAmount(),
- 'gm_amount' => $this->getGmAmount(),
- 'integral' => $this->getIntegral(),
- 'integral_money' => $this->getIntegralMoney(),
- 'rebate_amount' => $this->getRebateAmount(),
- 'payway' => $this->getPayway(),
- 'pay_time' => $this->getPayTime(),
- 'is_distribute' => $this->getIsDistribute(),
- ];
- return $_data;
- }
- /**
- * @return int
- */
- public function getAppId() {
- return $this->app_id;
- }
- /**
- * @param int $app_id
- */
- public function setAppId($app_id) {
- $this->app_id = $app_id;
- }
- /**
- * @return int
- */
- public function getStatus() {
- return $this->status;
- }
- /**
- * @param int $status
- */
- public function setStatus($status) {
- $this->status = $status;
- }
- }
|