-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] a canceled order may payed again and not show as dingads #2
Comments
Very valid. The original algorithm was effectively saying when an adid was We can fix it by replay the orders by time, but of there is other Jian Shuo 在 2012-9-1,下午3:05,Zhao Jun [email protected] 写道: eg. the adid of the ad is "1", and the first order last from 2012-01-01 to and array_diff will ignore the double existence, and return only ad 2, 3 $dingAds = array(1, 2, 3, 4, 1);$negAds = array(4, 1); so I do suggest not use negative order to fix the refund problem, cause — |
or change it to use neg to cancel order- compare orderid to remove, not adid Another known bug is, 0 price order cannot be cancelled this way. This will In the current design, the table should be called Service instead of order. I will go further on the service / order separation path by writing some Jian Shuo �$B:_�(B 2012-9-1�$B!$2<8a�(B3:42�$B!$�(BJian Shuo Wang [email protected] �$B<LF;!'�(B Very valid. The original algorithm was effectively saying when an adid was We can fix it by replay the orders by time, but of there is other Jian Shuo �$B:_�(B 2012-9-1�$B!$2<8a�(B3:05�$B!$�(BZhao Jun [email protected] �$B<LF;!'�(B eg. the adid of the ad is "1", and the first order last from 2012-01-01 to and array_diff will ignore the double existence, and return only ad 2, 3 $dingAds = array(1, 2, 3, 4, 1);$negAds = array(4, 1); so I do suggest not use negative order to fix the refund problem, cause �$B!=�(B |
I've tried to write single "service" instead of service + order today, and found it's really effective. and what I found more is we should create a "valid date" of any service. like if someone buy 50 refresh service, and we may make the valid days of one year. abstract class Service {
protected $status, $price, $listPrice, $userId, $startTime, $endTime, $days;
function purchase($params) {
foreach ($this->allowfields() as $key => $required) {
$this->$key = $params->$key;
if ($required && is_null($this->$key)) throw new Exception('need required field:' . $key);
}
$this->save();
}
function allowfields() {
return array('userId' => 1, 'days' => 1, 'listPrice' => 1);
}
function pay() {
if ($this->status == 'payed') throw new Exception('can not pay again!');
$time = time();
$this->startTime = $time;
$this->endTime = $time + $this->days * 86400;
$this->status = 'payed';
$this->price = $this->uc()->ratio * $this->listPrice;
$this->uc()->out($this->listPrice);
$this->save();
}
function uc() {
return new UserAccount($this->userId);
}
function cancel() {
}
abstract function shippedPercentage($time);
}
abstract class DaybasedService extends Service {
function shippedPercentage($time) {
return ;
}
}
class DingService extends DaybasedService {
function allowfields() {
return array('adId' => 1, 'category' => 1, 'area' => 1) + parent::allowfields();
}
} |
Some comments:
On Saturday, September 1, 2012, Zhao Jun wrote:
Jian Shuo Wang |
|
And one more thing. It's more effective to make one single service record to decide itself active or not. // a single record can decide active status, because the canceled service is no longer status "paid"
class Ad {
function isOnService($time) {
$activeService = graph("{$this->id}/service?status=paid&startTime=[,{$time}]&endTime=[{$time},]");
return count($activeService['data']) > 0;
}
}
//if we use neg service when refund.
class Ad {
function isOnService($time) {
$activeService = graph("{$this->id}/service?status=paid&startTime=[,{$time}]&endTime=[{$time},]");
$on = 0;
foreach ($activeService['data'] as $s) {
if ($s->price >= 0)
$on++;
else
$on--;
}
return $on > 0;
}
} And many other places we all need to do like this. |
I agree. Just need to find a solution that also works with Yifeng. You can 高奕峰186-2193-5860 Jian Shuo 在 2012-9-2,上午10:09,Zhao Jun [email protected] 写道: And one more thing. It's more effective to make one single service record // a single record can decide active status, because the canceled And many other places we all need to do like this. — |
On 7, yes. Days are first class data - most accurate. Start Time is also Jian Shuo 在 2012-9-2,上午9:32,Zhao Jun [email protected] 写道:
|
eg. the adid of the ad is "1", and the first order last from 2012-01-01 to 2012-12-31,
when he refund at 2012-08-01, we create a negative order.
but when it goes to payed again on 2012-09-01, so there will be 2 payed order now, and one in the neg array.
and array_diff will ignore the double existence, and return only ad 2, 3 without 1.
so I do suggest not use negative order to fix the refund problem, cause when we got only the active service, it's can not tell whether it's on or not!
The text was updated successfully, but these errors were encountered: